#!/bin/sh if [[ $# -eq 0 ]] ; then echo "lock-screen [ enable | disable | suspend | lock | start ]" exit fi case ${1} in locker-command) i3lock -c 536a77 -e -f -n ;; locker-command-fork) i3lock -c 536a77 -e -f ;; lock) ssh-add -D xidlehook-client --socket ~/.xidlehook.sock \ control --action trigger --timer 0 ;; daemon) [ -e ~/.xidlehook.sock ] && rm ~/.xidlehook.sock echo "Starting xidlehook" xidlehook --socket ~/.xidlehook.sock \ --not-when-fullscreen \ --not-when-audio \ --detect-sleep \ --timer 300 "lock-screen locker-command" "" ;; start) if ! ps aux | grep ' [x]idlehook ' > /dev/null ; then if ! tmux has-session -t 'screenlocker' ; then tmux new-session -s 'screenlocker' -n 'screenlocker' -d "$SHELL -c 'lock-screen daemon'" fi fi ;; disable) xidlehook-client --socket ~/.xidlehook.sock \ control --action disable --timer 0 ;; enable) xidlehook-client --socket ~/.xidlehook.sock \ controll --action enable --timer 0 ;; suspend) ssh-add -D lock-screen lock sleep 1 systemctl suspend ;; hibernate) ssh-add -D lock-screen lock sleep 1 systemctl hibernate ;; suspend-hibernate) ssh-add -D lock-screen lock sleep 1 systemctl suspend-hibernate ;; *) echo "lock-screen [ enable | disable | lock | start | suspend | hibernate | suspend-hibernate ]" esac