Skip to content

Instantly share code, notes, and snippets.

@steveblamey
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveblamey/11344909 to your computer and use it in GitHub Desktop.
Save steveblamey/11344909 to your computer and use it in GitHub Desktop.
Turn off gnome auto screen-lock when connected to specific wireless networks
#!/bin/sh -e
# Turn off gnome auto screen-lock when connected to specific wireless networks
# USAGE
# Add the following to /etc/pam.d/gdm-password, just after pam_gnome_keyring.so in the auth block:
# auth optional pam_exec.so quiet /usr/local/sbin/pam_auth_inhibit_lock
# Hat tip - md, http://blog.bofh.it/debian/id_444
WIRELESS_IFACE=wlan0
AUTH_ESSID=orchard
AUTH_USER=steve
# return the ESSID of this interface
current_essid() {
/sbin/iwconfig $1 | sed -nre '/ESSID/s/.*ESSID:"([^"]+)".*/\1/p'
}
# automatically unlock only for these users
case "$PAM_USER" in
"") echo "This program must be run by pam_auth.so!"
exit 1
;;
$AUTH_USER) ;;
*) exit 1
;;
esac
CURRENT_ESSID=$(current_essid $WIRELESS_IFACE)
# automatically turn off auto screen-lock when connected to these networks,
# otherwise turn on auto screen-lock
case "$CURRENT_ESSID" in
$AUTH_ESSID)
su -c "DISPLAY=:0 gsettings set org.gnome.desktop.screensaver lock-enabled false" $AUTH_USER
exit 1
;;
*)
su -c "DISPLAY=:0 gsettings set org.gnome.desktop.screensaver lock-enabled true" $AUTH_USER
exit 1
;;
esac
exit 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment