Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 21 lines (16 sloc) 733 Bytes
#!/bin/bash
HOTKEY="KEY_LEFTSHIFT"
# Write message to system log
/usr/bin/logger "Screen locked because Yubikey has been disconnected."
# Check, if hotkey is not beeing pressed during lockscreen attempt
kbd_devices=`cat /proc/bus/input/devices | egrep '^H:.* kbd ' | sed 's/.*event\([0-9]\+\).*/event\1/'`
for event_dev in ${kbd_devices}; do
evtest --query /dev/input/${event_dev} EV_KEY ${HOTKEY}
if [[ "$?" != "0" ]]; then
exit 0
fi
done
# For every user connected to DISPLAY:0, send DBUS message to lock screensaver
for user in `/usr/bin/who | /bin/grep ':0' | /usr/bin/awk '{print $1}' | /usr/bin/sort -u`; do
/bin/su ${user} -c 'DISPLAY=:0 /usr/bin/qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock'
done
You can’t perform that action at this time.