Notices


Reply
Thread Tools
Posts: 36 | Thanked: 28 times | Joined on Jul 2010
#1
Update: laasonen has made a program to do this! See this thread for details.

When I'm at home or work then there's not much point in having the lock code on my N900 but it's useful when I'm out. What would be great is if the "secure device" lock screen was disabled on certain wifi networks.

I can lock the device immediately (with phone-control --unlock) and I can run scripts depending on network connections (with dbus-scripts) but if I put the 2 together then my N900 locks/unlocks immediately.

Can any one point me in the right direction? I'd be appy with a command line dbus hack but a nice gui app would be even better.

Last edited by dave1010; 2011-04-11 at 06:42. Reason: app made
 

The Following 2 Users Say Thank You to dave1010 For This Useful Post:
jedi's Avatar
Posts: 1,411 | Thanked: 1,328 times | Joined on Jan 2010 @ Tatooine
#2
I like this idea. Sorry - I can't help but I'd like to see how this progresses
__________________
May the source be with you.
 
Posts: 1,320 | Thanked: 913 times | Joined on Feb 2010
#3
Have you tried out using dbus-monitor to see what the signal is to Lock the device?

That would give you the dbus commands needed and then you could possibly find a way to add that command to a script which activates based on your connection name?
__________________
Well Nokia do at least know how to build a decent phone, just apparently don't know how to support it..

N900 Died Replaced with N8, Requested E7, "Accidentally Broke E7", Now rolling with an N9 and im loving it!


My Contributions

N900 Conversations Wiki Page
 
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#4
Wrote simple script which unlocks the device when you click the power button when it's connected to the wlan you specified
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
		if [ `cat /sys/class/backlight/acx565akm/brightness` = "0" ]; then
			sleep 1
			dbus-send --system --type=method_call --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_tklock_mode_change string:"unlocked"
			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'
			echo "..opened";
		else 
			echo "..not locked!";
		fi
	else 
		echo "..not in home network!";
	fi
done
You need to run it as root, because user can't read /dev/input/pwrbutton
Comment the first dbus-send, if you miss the slider.

EDIT: Now it checks if the screen is unlocked already.

Last edited by laasonen; 2011-04-04 at 22:58.
 

The Following 5 Users Say Thank You to laasonen For This Useful 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.
 
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#6
Python version It is starting to be pretty decent, I'll upload it extras-devel later this week when I have time.
 

The Following 7 Users Say Thank You to laasonen For This Useful Post:
Posts: 36 | Thanked: 28 times | Joined on Jul 2010
#7
That's brilliant, thanks laasonen! Giving it a go now. I'm happy with editing a Python script but if it's going into extras then it'd be nice to have a GUI to edit the SSIDs.

I love the Maemo community.
 
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#8
Originally Posted by dave1010 View Post
That's brilliant, thanks laasonen! Giving it a go now. I'm happy with editing a Python script but if it's going into extras then it'd be nice to have a GUI to edit the SSIDs.

I love the Maemo community.
I was thinking of adding gconf-support and settings applet.
 
laasonen's Avatar
Posts: 565 | Thanked: 618 times | Joined on Jun 2010 @ Finland
#9
Any ideas for name?

Last edited by laasonen; 2011-04-08 at 16:56.
 
hawaii's Avatar
Posts: 1,030 | Thanked: 789 times | Joined on Jun 2009 @ Toronto
#10
WireLock? SSIDSecure? WiLock? Wi-Lo?
__________________
Blog: Know Nokia
 
Reply

Tags
d1ckheads, scripts

Thread Tools

 
Forum Jump


All times are GMT. The time now is 22:35.