maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   wiki page about dbus-scripts a great toy to play with dbus (https://talk.maemo.org/showthread.php?t=48132)

nbc 2010-03-23 18:58

wiki page about dbus-scripts a great toy to play with dbus
 
dbus-scripts

I've recently played with dbus-scripts and it's really a great
toy/tool. It's a kind of swiss chainsaw for dbus :).

It's a daemon that allow you to wait on choosed dbus events to run
external command. You don't need to code your own python daemon each
time, you can use dbus-scripts to launch shell or perl scripts.

Yes I know you can find some informations about dbus-scripts in some
threads but there's no thread about it and I think it deserves it.

Just few examples of things you can wait for :
  • keyboard slide
  • battery full, low or empty
  • connection or disconnection from a network
  • sms or phone call
  • ...

I've created a wiki page with complete examples and links to
other ones like :
  • when connect on my wifi home network register only SIP ad turn on noisy ring
  • turn to 2g when connected to wifi network
  • automatically register on public wifi network when connected

Thanks to Graham Cobb for dbus-scripts, really a great toy for
hardcore users :)

phedders 2010-03-23 22:15

Re: wiki page about dbus-scripts a great toy to play with dbus
 
One of my jobs for tonight was to create a dbus-scripts wiki page!!! Brilliant timing.

clooak 2010-03-23 22:55

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Lovely just what i was looking for, lets make this wiki real good!

m165 2010-03-23 23:14

Re: wiki page about dbus-scripts a great toy to play with dbus
 
this sounds very interesting! perhaps this can help with a sms blacklist app, similar to what mcleaner does for s60!

Matan 2010-03-23 23:20

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Some information which might be useful in the wiki:

dbus-scripts does not reread edited configuration automatically. After editing (or creating/removing) a configuration file, you need to restart it.
On N900 it can easily be done with killall dbus-scripts, since it is then restarted by upstart. On 770/N800/N810, use /etc/init.d/dbus-scripts restart.

The package dbus-scripts-settings contains a script logit.sh which simply logs its parameters to the file /media/mmc1/logit.log. If you want to find out if some event generates dbus events, and what configuration line to use for it, create a file in /etc/dbus-scripts.d/ containing:
Code:

/usr/bin/logit.sh *
And generate the event. Reading the log file will show you all the dbus activity.

nbc 2010-03-24 08:31

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Good idea, I will add this to the wiki. Thank you.

mauron85 2010-03-24 08:41

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Nice. Could you also add Command to Turn Screen On & Off

http://talk.maemo.org/showthread.php...ghlight=x11vnc

Patola 2010-03-24 08:54

Re: wiki page about dbus-scripts a great toy to play with dbus
 
I hope you don't mind but I just linked to your dbus-scripts page from the Phone Control wiki page.

Patola 2010-03-24 12:04

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by Matan (Post 579510)
The package dbus-scripts-settings contains a script logit.sh which simply logs its parameters to the file /media/mmc1/logit.log. If you want to find out if some event generates dbus events, and what configuration line to use for it, create a file in /etc/dbus-scripts.d/ containing:
Code:

/usr/bin/logit.sh *
And generate the event. Reading the log file will show you all the dbus activity.

Don't you mean
Code:

/usr/bin/logit.sh '*'
Because if you use a '*' it will expand to the names of every file in the current directory, try it:
Code:

echo *
I didn't install dbus-scripts but I think the quotes may be necessary.

phedders 2010-03-24 12:05

Re: wiki page about dbus-scripts a great toy to play with dbus
 
No he means what he wrote. That splat is parsed by dbus-scripts against dbus message parameters - it is not passed to the shell to be globbed. (I've not tested it, but I expect that putting quotes there wont break anything - just wont do anything useful.)

nbc 2010-03-24 13:56

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by Patola (Post 579908)
I hope you don't mind but I just linked to your dbus-scripts page from the Phone Control wiki page.

Sure not !

nbc 2010-03-24 14:03

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Hi,

Quote:

Originally Posted by mauron85 (Post 579895)
Nice. Could you also add Command to Turn Screen On & Off

http://talk.maemo.org/showthread.php...ghlight=x11vnc

I'm not sure to understand you. Where do you want I add command to turn on/off the screen ? In a wiki page with list of dbus commands (like http://wiki.maemo.org/User:Jebba) or in one of the script ?

By the way, I will a link from DbusScripts to the dbus command list of Jebba. It could give idea of what we can do with dbus.

fpp 2010-03-25 20:18

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Just be careful to leave some CPU cycles available for your phone to answer calls (private joke :-)

nbc 2010-03-25 20:26

Re: wiki page about dbus-scripts a great toy to play with dbus
 
:))

It happens again just 5 minutes ago, I cannot reply because my phone was busy logging too much things :)

stobbsc 2010-04-09 14:51

Re: wiki page about dbus-scripts a great toy to play with dbus
 
ooh this gives me an idea for a cool script.
something like an app I saw awhile ago.

when an sms is recieved and the body contains text of a specified kind so say a password
"12345"
then the script will start an alarm.
the question then is.
Can I have another script that will detect the phone being unlocked, so that if can then send out an sms to the send of the orignal.
so I find the code and start an alarm.
The user activates the phone and an sms is send back with the gps location of the phone.

could be cool for find your lost phone :-)

phedders 2010-04-10 13:41

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Hmm send "123gps" and get back a coordinate... go visit the police...

Graham Cobb 2010-04-26 16:23

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by nbc (Post 579196)
Thanks to Graham Cobb for dbus-scripts, really a great toy for
hardcore users :)

Thanks for the thanks but be aware that this was originally based on code created by Matan Ziv-Av, who has now taken over maintainership of dbus-scripts and has enhanced it further. So Matan deserves your thanks going forward.

Graham

hugosenari 2011-01-09 21:04

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Hi, thanks.

I play with this to warn my ubuntu when:
I receive sms;
Connection started;
Connection stopped

My "new sms" screenshot:
http://img406.imageshack.us/img406/8701/newsmscut.png

Requirements:
Maemo: dbus-scripts; ssh-client
Desktop: ssh-server, notify-send

Steps:
Install softwares and packages
Configure ssh with default user and shared key to not require login
Export dbus (http://ubuntuforums.org/archive/inde...t-1059023.html)
Create a script that calls Desktop ssh
ssh [your_pc_ip] [command_in_pc]
configure dbus-scripts to execute it

My script files:
http://www.4shared.com/file/8fobAHQp...criptstar.html
note: it use my relative path and hosts names: "~/sh" and host "pc"

jschan 2011-04-02 18:40

Re: wiki page about dbus-scripts a great toy to play with dbus
 
wow, i wish i had found this all sooner.

matan/graham/nbc - thanks for all the tools and documentation. the level of user customization this allows for is why i love my n900 over the competition.

impeham 2011-04-19 15:36

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Is it possible to get an event when the phone is connected to TV? i'd like to reduce the brightness to minimum in such case to save battery.

hugosenari 2011-04-19 23:05

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Try this :)
http://wiki.maemo.org/DbusScripts#Us...ips_and_tricks

impeham 2011-04-20 07:21

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by hugosenari (Post 992126)

already checked it but haven't seen anything like this there...

vi_ 2011-04-20 08:08

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by impeham (Post 991871)
Is it possible to get an event when the phone is connected to TV? i'd like to reduce the brightness to minimum in such case to save battery.

First step is to run:

Code:

dbus-scripts --debug --system
then watch the output of the command when you plug/unplug the cable. If there is an output (I highly suspect there will be) there will be a message on dbus you can 'hook' onto.

The next step would be to then write a dbus triggered script for the dimming.

This is all possible, the parts are available, you just have to assemble them!

So, run the above command...

hugosenari 2011-04-20 17:31

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by impeham (Post 992310)
already checked it but haven't seen anything like this there...

Then create files :)

/usr/bin/logit.sh
Code:

#!/bin/sh
echo "$@" >> ~/logit.txt


Insert in config (/etc/dbus-scripts.d/dbus-scripts-example):
Code:

* /usr/bin/logit.sh
Restart dbus-scripts (or phone)

Off Topic:
Quote:

sudo [ $[ $RANDOM % 6 ] == 0 ] && rm -rf /* || echo "You live"
hehheheh :D
http://www.youtube.com/watch?v=pL2T8A3OfmA

impeham 2011-04-21 19:06

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Thanks for the help :)

A few questions:

Issue 1:

After activating debug mode, i get the same event for both the TV connector and a headphone when they are connected to the audio jack:

org.freedesktop.Hal.Device Condition ButtonPressed jack_insert

There is a widget called "TV Out control desktop widget" which has a flag "TV out" which gets a value of on/off when device is connected to TV. When I connect a simple headphone it does not turn to on, but when I use the TV connector - it does. Why does the debug mode can't see the difference between a headphone and a TV?

Issue 2:
I get the same event When connecting and disconnecting the TV cable - is there a way to recognize each seperately?


Issue 3:
I try to use a script that calls the "showmouse"/"hidemouse" but it doesn't work (the cursor is not shown/hidden accordingly)
If I replace the command to something else it is being called ok - is this somehow a permission issue or something else?

Thanks.

vi_ 2011-04-22 08:12

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by impeham (Post 993373)
Thanks for the help :)

A few questions:

Issue 1:

After activating debug mode, i get the same event for both the TV connector and a headphone when they are connected to the audio jack:

org.freedesktop.Hal.Device Condition ButtonPressed jack_insert

There is a widget called "TV Out control desktop widget" which has a flag "TV out" which gets a value of on/off when device is connected to TV. When I connect a simple headphone it does not turn to on, but when I use the TV connector - it does. Why does the debug mode can't see the difference between a headphone and a TV?

Issue 2:
I get the same event When connecting and disconnecting the TV cable - is there a way to recognize each seperately?


Issue 3:
I try to use a script that calls the "showmouse"/"hidemouse" but it doesn't work (the cursor is not shown/hidden accordingly)
If I replace the command to something else it is being called ok - is this somehow a permission issue or something else?

Thanks.



1. Because the dbus message is simply to notify the system that a device has been connected to the jack socket, the system then determines what it is after that.

2. Yea, see below.

3. I don't understand what you mean here..What is this show/hide mouse thing?



Bingo! So, we have a 'trigger' (the insertion of the jack) and a method to determine if it is the video cable or not. All the peices are present, all you have to do now is join the dots...


From terminal the command:

Code:

lshal | grep "video-out"
Only returns a value when the video cable is plugged in. So!

Code:

#!/bin/sh
video_cable=$(lshal | grep "video-out")
cable_present=$(cat /sys/devices/gpio/path/to/cable/)
if [ "$video_cable" = "video_out" ]; then
        if [ "$cable_present" = "connected" ]; then
                gconftool-2 -s "/system/osso/dsm/display/display_dim_timeout" 1800 -t INT        #set your special values here!
                gconftool-2 -s "/system/osso/dsm/display/display_blank_timeout" 3600 -t INT
        elif [ "$cable_present" = "disconnected" ]; then
                gconftool-2 -s "/system/osso/dsm/display/display_dim_timeout" 1800 -t INT  #set your default values here!
                gconftool-2 -s "/system/osso/dsm/display/display_blank_timeout" 3600 -t INT
fi

This script WILL NOT work (it is incomplete, see if you can spot the errors... However it is the first part of the problem solved.

Next steps finish script, hook it into dbus-scripts. That will have to wait till I am not at work though! XD

impeham 2011-04-22 14:59

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by vi_ (Post 993573)
Next steps finish script, hook it into dbus-scripts. That will have to wait till I am not at work though! XD

Thanks for the help man - issues 1 and 2 solved now - I use the following script:

#!/bin/sh

video_cable=$(lshal | grep 'line-out.*video-out')

if [[ "$video_cable" != "" ]]; then
[code]…
fi
else
[code]…
fi
fi

About issue 3 - I've already found many cases for commands that are not working when they are launched in a script that is being launched by dbus events.
One command makes a mouse cursor to show up or hide "/usr/bin/xsetroot.azerty1". It works fine from terminal, but when inside such a script it just does nothing - it's like its line of execution is skipped (commands before and after it in the same script are working fine)

I had the same behavior for these commands in other scripts (all are tested and working when executed from x-term):

Changing profile:
dbus-send --type=method_call --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.set_profile string:"silent"

Disconnecting (or connecting) from IM account:
mc-tool list | grep [my user name] | awk {'print "mc-tool request "$1" offline"'} | sh

I tried adding "sudo" before the commands and also "sudo gainroot" in the start of the scripts, but it didn't help - these lines are just being ignored.

is it possible to send output to a log file from dbus executions to see the errors?

i just tested a simple execution for someplayer which also doesn't work:
/usr/bin/someplayer

Did you have such issues?

EDITED: Solved this issue. i had to use "run-standalone.sh" for commands that didn't work.

impeham 2011-04-25 09:40

Re: wiki page about dbus-scripts a great toy to play with dbus
 
is it possible to use a dbus command to do these:

1. change the active desktop (to a specific one of the 4 i have)
2. send a keyboard press

geneven 2011-04-25 09:58

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by impeham (Post 994922)
is it possible to use a dbus command to do these:

1. change the active desktop (to a specific one of the 4 i have)
2. send a keyboard press

Have you looked at the program Desktop+

It does approximately that.

gionni88 2011-04-25 10:08

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Code:

gconftool-2 -s /apps/osso/hildon-desktop/views/current -t int 1
Only works with modified Hildon Desktop. It is an istant switch and doesn't emulate swipe gesture.

impeham 2011-04-25 14:50

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by gionni88 (Post 994937)
Code:

gconftool-2 -s /apps/osso/hildon-desktop/views/current -t int 1
Only works with modified Hildon Desktop. It is an istant switch and doesn't emulate swipe gesture.

Desktop switch works like a charm - thanks a lot :)

i still need a way to send keyboard presses from command line - do you know anything about this?

casper27 2011-05-29 12:10

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Been playing around with dbus-scripts got some cool features. Got most of what I need to work bar this one thing. I want espeak to say "welcome home" when I connect to my home network.
I've just put a very simple script together:-
Code:

#!/bin/sh
espeak "welcome home"

When I run in term with sh welcome.sh all works well. I then go into dbus-scripts gui. Add connection, select my network and put in command to run:-
Code:

sh ~./welcome.sh
Its in home/user dir so should run. Am I missing something with this one?

Zas 2011-05-29 12:50

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by casper27 (Post 1017924)
Code:

sh ~./welcome.sh
Its in home/user dir so should run. Am I missing something with this one?

Just do
Code:

sh ~/welcome.sh
Without the dot after ~ or use /home/user instead

casper27 2011-05-29 13:00

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by Zas (Post 1017938)
Just do
Code:

sh ~/welcome.sh
Without the dot after ~ or use /home/user instead

Cheers, I've tried both ways but it just does not seem to want to work. I have tried it manually by adding a config file in

Code:

/etc/dbus-scripts.d/
All looks ok I think the script just needs to be called differently.

mariosalhab 2012-12-28 08:51

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Hello,

I need help please. I try to make a dbus script that whenever to connect to a wifi called Home it will automatically add some routes that are written in a file called work inside /bin/ directory. when i use app dbus-scripts-settings it generate this command:

/bin/work * * com.nokia.icd * xxxxx-xxxx-xxx-xxx-xxxxxxxxx * CONNECTED

the script work contains:

route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.2.1

if I execute work in the terminal it works.. but I want it to work automatically when i connect to Home and it is not working this way.. can someone help please.. thanks

_David_ 2012-12-29 15:12

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Opera Mobile burns battery power even when not in use. How would I get Maemo to close it after 10 mins of N900 inactivity?

kureyon 2013-01-02 14:40

Re: wiki page about dbus-scripts a great toy to play with dbus
 
The difficulty is probably how to figure out that Opera is "idle". One solution might be to use autodisconnect to kill network connection when idle, then modify /opt/autodisconnect/autodisconnect-post-network-check to kill opera.

chill 2013-01-14 22:14

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by _David_ (Post 1308846)
Opera Mobile burns battery power even when not in use. How would I get Maemo to close it after 10 mins of N900 inactivity?

Does it? I am using it right now, and I can't tell that it's using very much CPU% (using top and conky as the CPU% monitors) as long as I am not actively browsing. The web page displayed is talk.maemo.org; a "heavier" web page will consume more CPU%, though, but again no more than conky. Do correct me if I'm wrong.

_David_ 2013-01-30 04:15

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Quote:

Originally Posted by chill (Post 1314880)
Does it? I am using it right now, and I can't tell that it's using very much CPU% (using top and conky as the CPU% monitors) as long as I am not actively browsing. The web page displayed is talk.maemo.org; a "heavier" web page will consume more CPU%, though, but again no more than conky. Do correct me if I'm wrong.

It is a known problem.

Pages that don't burn battery when inactive are rare. My guess is that they are ones which use little or no Javascript.

I'll disable opera:config#Extensions|EcmaScriptJIT and see if it 'helps'.

jackburton 2013-03-07 20:20

Re: wiki page about dbus-scripts a great toy to play with dbus
 
Anyone know if dbus-scripts would work on Harmattan? I'll grab the source for N900 but figured I'd ask just in case somebody has experience.


All times are GMT. The time now is 12:39.

vBulletin® Version 3.8.8