Monday, March 14, 2016

How to Lock the Screen After Coming Back from Suspend (Sleep)

Locking the screen saver on hibernate or suspend

You may wish to run a screen locking utility when the system suspends (so that a password is required after waking up). This can be done by adding a script to the /etc/pm/sleep.d folder. Make sure the script is executable (chmod 755) and owned by root:root.

A simple example script is:

 #!/bin/sh   #   # 00screensaver-lock: lock workstation on hibernate or suspend     username= # add username here; i.e.: username=foobar   userhome=/home/$username   export XAUTHORITY="$userhome/.Xauthority"   export DISPLAY=":0"      case "$1" in      hibernate|suspend)         su $username -c "/usr/bin/slimlock" & # or any other such as /usr/bin/xscreensaver-command -lock      ;;      thaw|resume)      ;;      *) exit $NA      ;;   esac


Post a Comment