Created
January 21, 2018 07:37
-
-
Save nitheeshkl/af05640395fef59f0dbb3fd32f51a39f to your computer and use it in GitHub Desktop.
linux keylock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/udev/rules.d/60-keylock.rules | |
#ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="090c", ATTRS{idProduct}=="1000", ATTRS{serial}=="B1301100000946", SYMLINK+="keylock", RUN+="/lib/udev/keylock $env{ACTION}" | |
ACTION=="add", SUBSYSTEM=="usb", ENV{ID_VENDOR}=="090c", ENV{ID_MODEL}=="1000", ENV{ID_SERIAL_SHORT}=="B1301100000946",SYMLINK+="keylock", RUN+="/lib/udev/keylock $env{ACTION}" | |
ACTION=="remove", SUBSYSTEM=="usb", ENV{ID_VENDOR_ID}=="090c", ENV{ID_MODEL}=="1000", RUN+="/lib/udev/keylock $env{ACTION}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/lib/udev/keylock | |
#!/bin/bash | |
state=$1 | |
user=`ps aux | grep gnome-screensaver | head -n 1 | awk '{print $1}'` | |
echo "udev: key $1" >> /var/log/keylock.log | |
if [ -n $user ]; then | |
#GNOME_SCREENSAVER_PROC=`ps xa | grep gnome-screensaver | head -n 1 | awk '{print $1}'` | |
#export `grep -z DBUS_SESSION_BUS_ADDRESS /proc/$GNOME_SCREENSAVER_PROC/environ` | |
export DISPLAY=":0" | |
case $state in | |
"add"): | |
#su $user -c "gconftool-2 --set "/apps/gnome-screensaver/lock_enabled" --type bool 0" | |
su $user -c "/usr/bin/xscreensaver-command -deactivate" &>>/var/log/keylock.log | |
;; | |
"remove"): | |
#su $user -c "gconftool-2 --set "/apps/gnome-screensaver/lock_enabled" --type bool 1" | |
#su $user -c "/usr/bin/xscreensaver-command -lock" &>>/var/log/keylock.log | |
/usr/bin/xscreensaver-command -lock &>>/var/log/keylock.log | |
#vlock --all | |
;; | |
esac | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment