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)

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.


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

vBulletin® Version 3.8.8