2023-05-03 10:19:35 -04:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
# A dmenu wrapper script for system functions.
|
|
|
|
|
export WM=$XDG_CURRENT_DESKTOP
|
|
|
|
|
case "$(readlink -f /sbin/init)" in
|
|
|
|
|
*systemd*) ctl='systemctl' ;;
|
|
|
|
|
*) ctl='loginctl' ;;
|
|
|
|
|
esac
|
|
|
|
|
|
2023-06-18 06:39:43 -04:00
|
|
|
|
case "$(printf "🔒 lock\n🚪 leave $WM\n♻️ renew $WM\n🐻 hibernate\n🔃 reboot\n🖥️ shutdown\n💤 sleep\n📺 display off\n set background\n start idle\n kill swayidle\n fcitx5\n kill fcitx5\n start emacs daemon\n kill emacs daemon\n restart emacs daemon" | dmenu -i -l 16 -p 'Action: ')" in
|
2023-05-03 10:19:35 -04:00
|
|
|
|
'🔒 lock')
|
|
|
|
|
setsid -f swaylock
|
2023-05-04 11:14:03 -04:00
|
|
|
|
setsid -f sleep 2 && swayidle -w timeout 1 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on" && kill $#'
|
2023-05-03 10:19:35 -04:00
|
|
|
|
;;
|
|
|
|
|
"🚪 leave $WM") swaymsg exit ;;
|
2023-06-18 06:39:43 -04:00
|
|
|
|
"♻️ renew $WM") swaymsg reload ;;
|
2023-05-03 10:19:35 -04:00
|
|
|
|
'🐻 hibernate') $ctl hibernate -i ;;
|
|
|
|
|
'💤 sleep') $ctl suspend -i ;;
|
|
|
|
|
'🔃 reboot') $ctl reboot -i ;;
|
|
|
|
|
'🖥️ shutdown') $ctl poweroff -i ;;
|
2023-06-18 06:39:43 -04:00
|
|
|
|
'📺 display off') swayidle -w timeout 1 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on" && kill $#' ;;
|
2023-05-03 10:19:35 -04:00
|
|
|
|
' set background') change-background ;;
|
2023-06-18 06:39:43 -04:00
|
|
|
|
' start idle') killall swayidle && sleep 1; setsid -f idle && notify-send 'idle started.';;
|
|
|
|
|
' kill swayidle') killall swayidle && notify-send 'idle killed.';;
|
2023-05-03 10:19:35 -04:00
|
|
|
|
' fcitx5') fcitx5 ;;
|
|
|
|
|
' kill fcitx5') killall fcitx5 ;;
|
2023-05-04 11:14:03 -04:00
|
|
|
|
' start emacs daemon') emacs --daemon && notify-send 'emacs daemon started' ;;
|
|
|
|
|
' kill emacs daemon') killall emacs && notify-send 'emacs daemon killed' ;;
|
2023-06-18 06:39:43 -04:00
|
|
|
|
' restart emacs daemon') killall emacs && notify-send 'emacs daemon killed' ; emacs --daemon && notify-send 'emacs daemon started' ;;
|
2023-05-03 10:19:35 -04:00
|
|
|
|
*) exit 1 ;;
|
|
|
|
|
esac
|