dotfiles/home/default/.local/bin/sysact

49 lines
3.1 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# A dmenu wrapper script for system functions.
#export WM=$XDG_CURRENT_DESKTOP
if [ "$WINDOW_MANAGER" == "sway" ]; then WM="sway" ; fi
if [ "$WINDOW_MANAGER" == "river" ]; then WM="river" ; fi
case "$(readlink -f /sbin/init)" in
*systemd*) ctl='systemctl' ;;
*) ctl='loginctl' ;;
esac
#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" | rofi -dmenu -i -l 16 -p 'action')" in
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\ntoggle sworkstyle" | wofi -L 17 --cache-file=/dev/null --show=dmenu -i -p 'action')" in
'🔒 lock')
setsid -f swaylock
if [ "$WINDOW_MANAGER" == "river" ]; then setsid -f sleep 2 && swayidle -w timeout 1 'wlopm --off "*"' resume 'wlopm --on "*" && kill $#' ; fi
if [ "$WINDOW_MANAGER" == "sway" ]; then setsid -f sleep 2 && swayidle -w timeout 1 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on" && kill $#' ; fi
;;
"🚪 leave $WM")
if [ "$WINDOW_MANAGER" == "sway" ]; then swaymsg exit ; fi
if [ "$WINDOW_MANAGER" == "river" ]; then riverctl exit ; fi
;;
"♻️ renew $WM")
if [ "$WINDOW_MANAGER" == "sway" ]; then swaymsg reload ; fi
if [ "$WINDOW_MANAGER" == "river" ]; then $HOME/.config/river/init ; fi
;;
'🐻 hibernate') $ctl hibernate -i ;;
'💤 sleep') $ctl suspend -i ;;
'🔃 reboot') $ctl reboot -i ;;
'🖥️ shutdown') $ctl poweroff -i ;;
#'📺 display off') swayidle -w timeout 1 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on" && kill $#' ;;
'📺 display off')
if [ "$WINDOW_MANAGER" == "river" ]; then setsid -f sleep 2 && swayidle -w timeout 1 'wlopm --off "*"' resume 'wlopm --on "*" && kill $#' ; fi
if [ "$WINDOW_MANAGER" == "sway" ]; then setsid -f sleep 2 && swayidle -w timeout 1 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on" && kill $#' ; fi
;;
' set background') change-background ;;
' start idle') killall swayidle && sleep 1; setsid -f idle && notify-send 'idle started.';;
' kill swayidle') killall swayidle && notify-send 'idle killed.';;
' fcitx5') fcitx5 ;;
' kill fcitx5') killall fcitx5 ;;
#' start emacs daemon') emacs --daemon && emacsclient -c ;;
#' kill emacs daemon') emacsclient -e '(kill-emacs)' ;;
#' restart emacs daemon') emacsclient -e '(kill-emacs)' ; emacs --daemon && emacsclient -c ;;
' start emacs daemon') emacs --daemon && notify-send 'emacs daemon started' ;;
' kill emacs daemon') emacsclient -e '(kill-emacs)' && notify-send 'emacs daemon killed' ;;
' restart emacs daemon') emacsclient -e '(kill-emacs)' && notify-send 'emacs daemon killed' ; emacs --daemon && notify-send 'emacs daemon started' ;;
*) exit 1 ;;
esac