mirror of https://gitlab.com/dabruh/dotfiles.git
51 lines
932 B
Bash
Executable File
51 lines
932 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# i3exit
|
|
#
|
|
# Provide simple arguments for various locking and power related tasks.
|
|
|
|
# with openrc use loginctl
|
|
[[ $(cat /proc/1/comm) == "systemd" ]] && logind=systemctl || logind=loginctl
|
|
|
|
function lock() {
|
|
xscreensaver-command -lock
|
|
}
|
|
|
|
case "$1" in
|
|
lock)
|
|
lock
|
|
;;
|
|
logout)
|
|
i3-msg exit
|
|
;;
|
|
switch_user)
|
|
dm-tool switch-to-greeter
|
|
;;
|
|
suspend)
|
|
lock && $logind suspend
|
|
;;
|
|
hibernate)
|
|
lock && $logind hibernate
|
|
;;
|
|
reboot)
|
|
$logind reboot
|
|
;;
|
|
shutdown)
|
|
$logind poweroff
|
|
;;
|
|
commands)
|
|
echo "lock,logout,switch_user,suspend,hibernate,reboot,shutdown"
|
|
;;
|
|
help)
|
|
cmds="$($0 commands)"
|
|
echo "Usage: $0 ${cmds//\,/\, }"
|
|
;;
|
|
*)
|
|
echo "== ! i3exit: missing or invalid argument ! =="
|
|
$0 help
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
exit 0
|