My iPhone is connected via USB to my Ubuntu desktop via a dock. How do I configure it so that when I dock my phone the screen is unlocked and when removing it it locks it?
Found an excellent script here courtesy of Evan Boldt on how to do this. Thanks Evan!
First find out the id of your device by using lsusb
The create a script under your home dir (let's use /home/me/iPhoneLock.sh for this example) that looks sort of like this:
Next, edit your crontab:
Finally configure it so that it runs every minute:
Note of warning though: Of course this means that anyone with your phone will be able to unlock your screen. A nice improvement would be to only unlock your screen if your phone was unlocked.
This of course is applicable to any usb device.
The script is licensed under the CC-GNU GPL version 2.0 or later.
even simpler script
use lsusb to get the device id of the usb device you want to use as your "key" and replace it in this script (called checkKey.sh)
then just cron this to run every few minutes... this way it will start up again if it stops for some reason.... the script should run continuously, but will exit if cron tries to run a second copy. To have cron affect a GUI app, like the screen saver, you have to tell it which display to use, so put this in your crontab (obviously set the path properly)