42 lines
991 B
Bash
42 lines
991 B
Bash
#!/bin/sh
|
|||
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||
|
|
# Copyright 2022 Sxmo Contributors
|
||
|
|
|
||
|
|
# shellcheck source=scripts/core/sxmo_common.sh
|
||
|
|
. sxmo_common.sh
|
||
|
|
|
||
|
|
usage() {
|
||
|
|
printf "usage: %s [reboot|poweroff|logout|togglewm]\n" "$(basename "$0")"
|
||
|
|
}
|
||
|
|
|
||
|
|
case "$1" in
|
||
|
|
reboot)
|
||
|
|
sxmo_hook_power.sh reboot || true
|
||
|
|
sxmo_jobs.sh stop all >/dev/null 2>&1 || true
|
||
|
|
sync
|
||
|
|
(sleep 5; doas /sbin/reboot -f >/dev/null 2>&1) &
|
||
|
|
doas /sbin/reboot || doas reboot || doas /sbin/reboot -f
|
||
|
|
;;
|
||
|
|
poweroff)
|
||
|
|
sxmo_hook_power.sh poweroff || true
|
||
|
|
sxmo_jobs.sh stop all >/dev/null 2>&1 || true
|
||
|
|
sync
|
||
|
|
(sleep 5; doas /sbin/poweroff -f >/dev/null 2>&1) &
|
||
|
|
doas /sbin/poweroff || doas poweroff || doas /sbin/poweroff -f
|
||
|
|
;;
|
||
|
|
logout)
|
||
|
|
sxmo_hook_logout.sh || true
|
||
|
|
case "$SXMO_WM" in
|
||
|
|
"i3") i3-msg exit ;;
|
||
|
|
"sway") swaymsg exit ;;
|
||
|
|
"river") riverctl exit ;;
|
||
|
|
"dwm") pkill dwm ;;
|
||
|
|
esac
|
||
|
|
;;
|
||
|
|
togglewm) sxmo_togglewm.sh ;;
|
||
|
|
*)
|
||
|
|
usage
|
||
|
|
exit 1
|
||
|
|
;;
|
||
|
|
esac
|