2022-06-07 11:50:08 +02:00
|
|
|
#!/bin/bash
|
2022-06-08 21:23:51 +02:00
|
|
|
|
|
|
|
# i3exit
|
|
|
|
#
|
|
|
|
# Provide simple arguments for various locking and power related tasks.
|
2022-06-07 11:50:08 +02:00
|
|
|
|
|
|
|
# with openrc use loginctl
|
|
|
|
[[ $(cat /proc/1/comm) == "systemd" ]] && logind=systemctl || logind=loginctl
|
|
|
|
|
2024-02-29 12:30:23 +01:00
|
|
|
function lock() {
|
|
|
|
xscreensaver-command -lock
|
2022-06-07 11:50:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
lock)
|
2024-02-29 12:30:23 +01:00
|
|
|
lock
|
2022-06-07 11:50:08 +02:00
|
|
|
;;
|
|
|
|
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
|
|
|
|
;;
|
2022-06-07 12:54:09 +02:00
|
|
|
commands)
|
|
|
|
echo "lock,logout,switch_user,suspend,hibernate,reboot,shutdown"
|
|
|
|
;;
|
|
|
|
help)
|
|
|
|
cmds="$($0 commands)"
|
|
|
|
echo "Usage: $0 ${cmds//\,/\, }"
|
|
|
|
;;
|
2022-06-07 11:50:08 +02:00
|
|
|
*)
|
|
|
|
echo "== ! i3exit: missing or invalid argument ! =="
|
2022-06-07 12:54:09 +02:00
|
|
|
$0 help
|
2022-06-07 11:50:08 +02:00
|
|
|
exit 2
|
2022-06-10 17:30:12 +02:00
|
|
|
;;
|
2022-06-07 11:50:08 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|