View Single Post
joerg_rw's Avatar
Posts: 2,222 | Thanked: 12,651 times | Joined on Mar 2010 @ SOL 3
#14
another approach:
apt-get install dbus-scripts
or install dbus-scripts via App Manager

add these 2(!) lines to /etc/dbus-scripts.d/dbus-scripts-settings (create the file if it doesn't exist)
Code:
#:soundonslide
/etc/dbus-scripts-scripts/playswoosh * * org.freedesktop.Hal.Device Condition ButtonPressed cover
create a folder /etc/dbus-scripts-scripts, and a file therein named playswoosh (my StarTrek style sound on slide out kbd, I'll just augment the code a bit here for the requested purpose). Set the file `chmod +x`

place following code to /etc/dbus-scripts-scripts/playswoosh:
Code:
#!/bin/sh
stored=/home/user/.slidestore;
slide=$(cat sys/devices/platform/gpio-switch/slide/state);
if [ X$slide == X$(cat $stored) ]; then exit 0; fi;
if [ X$slide == Xopen ]; then 
  /usr/bin/play-sound /usr/share/sounds/ui-charging_started.wav;
##next two lines are new and untested :-) and relevant for locking the screen
else
  /usr/bin/dbus-send --system --type=method_call \
    --dest=com.nokia.mce /com/nokia/mce/request \
    com.nokia.mce.request.req_tklock_mode_change string:"locked"
fi;
echo -n $slide >$stored
if you don't like the slide-out-swoosh, do this instead:
Code:
#!/bin/sh
stored=/home/user/.slidestore;
slide=$(cat sys/devices/platform/gpio-switch/slide/state);
if [ X$slide == X$(cat $stored) ]; then exit 0; fi;
if [ X$slide != Xopen ]; then 
  /usr/bin/dbus-send --system --type=method_call \
    --dest=com.nokia.mce /com/nokia/mce/request \
   com.nokia.mce.request.req_tklock_mode_change string:"locked"
fi;
echo -n $slide >$stored
Sorry for not actually testing it, if it has a typo, please let me know :-)
[edit] If somebody has this original chirping sound of Kirk's communicator, please toss it over. For the protocol: I know $stored better be a file in /tmp, feel free to edit.
[edit2] If you want to do other nice things with dbus-scripts, use dbus-monitor to find out about the dbus signal match-pattern to add to /etc/dbus-scripts.d/* (where * is any file, either the existing dbus-scripts-settings, or an arbitrary file you create for your new action)

cheers
jOERG
__________________
Maemo Community Council member [2012-10, 2013-05, 2013-11, 2014-06 terms]
Hildon Foundation Council inaugural member.
MCe.V. foundation member

EX Hildon Foundation approved
Maemo Administration Coordinator (stepped down due to bullying 2014-04-05)
aka "techstaff" - the guys who keep your infra running - Devotion to Duty http://xkcd.com/705/

IRC(freenode): DocScrutinizer*
First USB hostmode fanatic, father of H-E-N

Last edited by joerg_rw; 2010-12-15 at 17:11.
 

The Following 4 Users Say Thank You to joerg_rw For This Useful Post: