View Single Post
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#5
I was trying to add a smarter way to detect the lock, but I can't figure out why it says that device is locked even thought it's not?
Code:
Nokia-N900:~# dbus-send --system --type=method_call --dest="com.nokia.mce" --print-reply "/com/nokia/mce/request" com.nokia.mce.request.get_devicelock_mode
method return sender=:1.9 -> dest=:1.218 reply_serial=2
   string "locked"
Nokia-N900:~#
Keyboard and screen lock detecting seems to work:
Code:
Nokia-N900:~# dbus-send --system --type=method_call --dest="com.nokia.mce" --print-reply "/com/nokia/mce/request" com.nokia.mce.request.get_tklock_mode
method return sender=:1.9 -> dest=:1.241 reply_serial=2
   string "unlocked"
Nokia-N900:~#
EDIT: It seems to work now :/

Better one:
Code:
#!/bin/sh
homeESSID="Home_1" #Set up your ESSID

while true; do
	cat /dev/input/pwrbutton | echo "Waiting.."
	echo "Trying to open.."
	if [ `iwconfig wlan0 | grep ESSID | awk -F'"' '{print $2}'` = $homeESSID ];	then #Correct wlan?
		echo "..opening.."
		dbus-send --system --type=method_call --dest="com.nokia.mce" --print-reply "/com/nokia/mce/request" com.nokia.mce.request.get_devicelock_mode | grep unlocked > /dev/null
		devicelock=$?
		dbus-send --system --type=method_call --dest="com.nokia.mce" --print-reply "/com/nokia/mce/request" com.nokia.mce.request.get_tklock_mode | grep unlocked > /dev/null
		tklock=$?
		echo $devicelock
		echo $tklock
		if [ $devicelock = 1 || $tklock = 1 ]; then #Need sleep?
			sleep 1
		fi
		if [ $devicelock = 1 ]; then #Device lock?
			dbus-send --system --type=method_call --dest=com.nokia.system_ui /com/nokia/system_ui/request com.nokia.system_ui.request.devlock_close string:"com.nokia.mce" string:"/com/nokia/mce/request" string:"com.nokia.mce.request" string:"devlock_callback" uint32:'0'
		fi
		if [ $tklock = 1 ]; then #Device lock?
			dbus-send --system --type=method_call --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_tklock_mode_change string:"unlocked"
		fi
		echo "..opened!"
	else 
		echo "..not in home network!"
	fi
done
After couple unlocks the power button stops opening the menu :/ I'll make better one with python

Last edited by laasonen; 2011-04-05 at 20:38.