View Single Post
Posts: 4 | Thanked: 6 times | Joined on Dec 2010 @ Cologne
#6
Here is my (indeed very ugly) solution to this:

You'll need dbus-scripts. Install if you don't already have it:

Code:
# wget http://repository.maemo.org/extras-devel/pool/fremantle/free/d/dbus-scripts/dbus-scripts_1.0+maemo-5_armel.deb
# dpkg -i dbus-scripts_1.0+maemo-5_armel.deb
Create this script under /usr/bin/closelock.sh:

Code:
#!/bin/sh

if [ "$4" == "tklock_mode_ind" ]; then
	echo $5 > /tmp/lockmode
fi

if [ "$6" == "cover" ]; then
	if [ `cat /tmp/lockmode` == "unlocked" ]; then
		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
fi
Append the following rules to /etc/dbus-scripts.d/dbus-scripts:

Code:
/usr/bin/closelock.sh * * org.freedesktop.Hal.Device Condition ButtonPressed cover
/usr/bin/closelock.sh * * com.nokia.mce.signal tklock_mode_ind
The script saves the locking state (locked or unlocked) in /tmp/lockmode. Whenever the "ButtonPressed cover" occurs (i.e. the keyboard has been closed or opened) and if lockmode is unlocked, a dbus event is sent to lock the screen.

Use at your own risk
 

The Following 2 Users Say Thank You to sebhack For This Useful Post: