2017-08-10 14:49:50 +03:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
|
2019-10-21 17:28:37 +03:00
|
|
|
pidfile=${XDG_RUNTIME_DIR-/run/user/$UID}/xscreensaver-companion.pid
|
|
|
|
trap "rm -f $pidfile" INT KILL
|
|
|
|
|
|
|
|
function init_pidfile
|
|
|
|
{
|
|
|
|
local pid
|
|
|
|
if read pid < $pidfile; then
|
|
|
|
if kill -0 $pid; then
|
|
|
|
echo 'I am already running!' >&2
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo 'Remove stale lock file.' >&2
|
|
|
|
rm $pidfile
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo $$ > $pidfile
|
|
|
|
}
|
|
|
|
|
2017-08-10 14:49:50 +03:00
|
|
|
function parse_actions
|
|
|
|
{
|
|
|
|
while read action _; do
|
|
|
|
case $action in
|
|
|
|
(LOCK|BLANK)
|
|
|
|
/usr/bin/setxkbmap us -option
|
2017-11-28 12:55:22 +02:00
|
|
|
/usr/bin/numlockx off
|
2017-08-10 14:49:50 +03:00
|
|
|
/usr/bin/notify-send DUNST_COMMAND_PAUSE
|
|
|
|
;;
|
|
|
|
(UNBLANK)
|
2019-10-21 16:45:58 +03:00
|
|
|
$HOME/git/mine/vscripts/mykblayouts
|
2017-08-10 14:49:50 +03:00
|
|
|
/usr/bin/notify-send DUNST_COMMAND_RESUME
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2019-10-21 17:28:37 +03:00
|
|
|
init_pidfile
|
2017-08-10 14:49:50 +03:00
|
|
|
/usr/bin/xscreensaver-command -watch | parse_actions
|