scripts reorganize
This commit is contained in:
78
scripts/WMScripts/exit.sh
Executable file
78
scripts/WMScripts/exit.sh
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# This script cleanly exits a variety of window managers, depending on the given parameters
|
||||
# Also checks no windows exist on the scratchpad (as I tend to forget about those)
|
||||
|
||||
|
||||
case "$XDG_CURRENT_DESKTOP" in
|
||||
"Hyprland")
|
||||
lock="hyprlock"
|
||||
cmd="hyprctl clients -j | jq . | grep -E 'special' -c"
|
||||
ctl="hyprctl dispatch"
|
||||
logout="uwsm stop"
|
||||
;;
|
||||
"sway")
|
||||
lock="swaylock --screenshots --clock --indicator --indicator-radius 100 --indicator-thickness 7 --effect-pixelate 25 -- effect-vignette 0.5:0.5 --ring-color 244273a --key-hl-color c6a0f6 --line-color 00000000 --inside-color 00000000 --separator-color 00000000"
|
||||
cmd="swaymsg -rt get_tree | jq . | grep -E 'scratchpad_state\": \"(changed|fresh)' -c"
|
||||
ctl="swaymsg"
|
||||
logout="swaymsg exit"
|
||||
;;
|
||||
"i3")
|
||||
lock='i3lock -n -c 18192666 -k --radius 180 --inside-color=24273a --layout-color=cad3f5 --time-color=cad3f5 --date-color=cad3f5 --greeter-color=cad3f5 --verif-color=cad3f5 --wrong-color=cad3f5 --modif-color=cad3f5 --ring-color=c6a0f6 --insidever-color=24273a --ringver-color=8aadf4 --insidewrong-color=24273a --ringwrong-color=ed8796 --keyhl-color=a6da95 --bshl-color=f5a97f --separator-color=24273a --date-str="%A, %d %B %Y"'
|
||||
cmd="i3-msg -t get_tree | jq . | grep -E 'scratchpad_state\": \"(changed|fresh)' -c"
|
||||
ctl="i3-msg"
|
||||
logout="i3-msg exit"
|
||||
;;
|
||||
*)
|
||||
dunstify -u low -t 2000 -i ~/.icons/candy-icons/apps/scalable/system-shutdown.svg "This desktop is not supported."
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
spec_exist() {
|
||||
n=$(eval "$cmd")
|
||||
|
||||
if [ "$n" -gt 0 ]; then
|
||||
[ "$n" -gt 1 ] && msg="$n windows" || msg="window"
|
||||
dunstify -t 3000 \
|
||||
-u low \
|
||||
-i ~/.icons/candy-icons/apps/scalable/system-shutdown.svg \
|
||||
-a i3exit \
|
||||
"Close the $msg in the scratchpad first."
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
lock() {
|
||||
dunstctl set-paused true
|
||||
bash -c "$lock"
|
||||
dunstctl set-paused false
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
lock)
|
||||
lock
|
||||
;;
|
||||
logout)
|
||||
eval "$logout"
|
||||
;;
|
||||
suspend)
|
||||
systemctl suspend && lock
|
||||
;;
|
||||
hibernate)
|
||||
systemctl hibernate && lock
|
||||
;;
|
||||
reboot)
|
||||
spec_exist
|
||||
systemctl reboot
|
||||
;;
|
||||
shutdown)
|
||||
spec_exist
|
||||
systemctl poweroff
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
|
||||
exit 2
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user