You can have your Linux screen automatically unlock its screen when any USB device is plugged in. You'll find this usefull espcially if you have a cell phone that you charge using your computer.
All you have to do is type
lsusb into the terminal, copy the part after "ID ".
Then paste this into a file in your /home/USERNAME/bin/ directory.
#Replace with the ID of your USB device
id="ID 05ac:1292 Apple, Inc" # Example: id="ID 05ac:1292 Apple, Inc"
#runs every 2 seconds
for ((i=0; i<=30; i++))
if [ -z "`lsusb | grep "$id"`" ]
echo "Device is NOT plugged in"
if [ -n "`DISPLAY=:0 gnome-screensaver-command --query | grep "is active"`" ]
if [ -e /home/evan/bin/autoUnlock.lock ]
#stop locking the screen
elif [ -e /home/evan/bin/autoUnlock.lock ]
DISPLAY=:0 notify-send -t 5000 --icon=dialog-info "Device Disconnected" "Bye!"
#lock the desktop
DISPLAY=:0 gnome-screensaver-command --lock
echo "iPhone IS plugged in"
if [ ! -e /home/evan/bin/autoUnlock.lock ]
DISPLAY=:0 gnome-screensaver-command --deactivate
DISPLAY=:0 notify-send -t 5000 --icon=dialog-info "Device Connected" "Welcome Back!"
##Uncomment the 3 following lines if you would like your computer to remind you if you lock your screen without disconnecting the device
#echo "Don't forget your device!" > /home/evan/bin/iPhoneReminder
#DISPLAY=:0 festival --tts /home/evan/bin/iPhoneReminder
You should paste the ID you copied earlier to the apropriate place in the top of the file.
If you would like to be reminded in case you forget your device, uncomment the 3 lines in the middle of the file.
Next, have your Linux compter run this script every minute.
add the line:
* * * * * bash /home/username/bin/autoUnlock & >/dev/null 2>&1
That should be all you need!
The script is licensed under the CC-GNU GPL version 2.0 or later.