1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#!/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_reboot.sh
sxmo_daemons.sh stop all
doas reboot
;;
poweroff)
sxmo_hook_poweroff.sh
sxmo_daemons.sh stop all
doas poweroff
;;
logout)
sxmo_hook_logout.sh
case "$SXMO_WM" in
"sway") swaymsg exit ;;
"dwm") pkill dwm ;;
esac
;;
togglewm)
case "$(realpath /var/lib/tinydm/default-session.desktop)" in
*"swmo.desktop")
if command -v dwm > /dev/null; then
if doas tinydm-set-session -f -s "$(xdg_data_path xsessions/sxmo.desktop)"; then
sxmo_hook_logout.sh
swaymsg exit
else
sxmo_notify_user.sh "You do not have tinydm installed."
fi
else
sxmo_notify_user.sh "You do not have dwm installed."
fi
;;
*"sxmo.desktop")
if command -v sway >/dev/null; then
if doas tinydm-set-session -f -s "$(xdg_data_path wayland-sessions/swmo.desktop)"; then
sxmo_hook_logout.sh
pkill dwm
else
sxmo_notify_user.sh "You do not have tinydm installed."
fi
else
sxmo_notify_user.sh "You do not have sway installed."
fi
;;
esac
;;
*)
usage
exit 1
;;
esac
|