diff options
Diffstat (limited to '.local/bin/desktop/i3exit')
-rwxr-xr-x | .local/bin/desktop/i3exit | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/.local/bin/desktop/i3exit b/.local/bin/desktop/i3exit new file mode 100755 index 0000000..0be387c --- /dev/null +++ b/.local/bin/desktop/i3exit @@ -0,0 +1,54 @@ +#!/bin/sh + +# with openrc use loginctl +[ "$(cat /proc/1/comm)" = "systemd" ] && logind=systemctl || logind=loginctl + +command="$1" +system_control() { + if [ "$(loginctl show-session --property=NCurrentSessions --value)" -gt 2 ]; then + notify-send --replace-id=4252 \ + "i3exit" "Multiple users are logged in\nCant't $command" + exit + fi + eval "$@" +} + +lockWall="$HOME/.local/share/lockWall" +lock_desktop() { + [ -f "$lockWall" ] && + i3lock --tiling --image="$lockWall" || + i3lock --color=001177 + pkill ssh-agent +} + +case "$command" in + lock) + lock_desktop + xset dpms force off + ;; + logout) + switch-session + i3-msg exit + ;; + switch_user) + dm-tool switch-to-greeter + ;; + suspend) + lock_desktop; $logind suspend + ;; + hibernate) + system_control lock_desktop && $logind hibernate + ;; + reboot) + system_control $logind reboot + ;; + shutdown) + system_control $logind poweroff + ;; + *) + echo "== ! i3exit: missing or invalid argument ! ==" + echo "Try again with: lock | logout | switch_user | suspend | hibernate | reboot | shutdown" + exit 2 +esac + +exit 0 |