scripts/sway/power-menu.sh

49 lines
1.8 KiB
Bash
Raw Normal View History

2020-09-11 15:00:39 +00:00
#!/bin/bash
# Passwordless sudo required for systemctl [reboot|poweroff|hibernate]
# Determine if Sway or i3
if [ -z ${SWAYSOCK+x} ]; then
2023-01-06 19:41:31 +00:00
WM="i3"
2020-09-11 15:00:39 +00:00
else
2023-01-06 19:41:31 +00:00
WM="sway"
2020-09-11 15:00:39 +00:00
fi
if [[ $WM == 'i3' ]]; then
2023-01-06 19:41:31 +00:00
res=$(printf "⚿ Lock|↩ Logout|↻ Reload i3|↹ Restart i3|↯ Hibernate|🡙 Reboot|⏻ Shutdown" | rofi -sep "|" -dmenu -i -p 'Power: ' "" -columns 1 -rows 7 -width 32 -l 1 -theme /home/jpm/.config/rofi/sidebar.rasi -hide-scrollbar -eh 1 -location 0 -padding 12 -opacity 100 -auto-select -no-fullscreen)
2020-09-11 15:00:39 +00:00
else
2023-01-06 19:41:31 +00:00
res=$(printf "⚿ Lock\n🖵 Toggle Displays\n⚿ Yubico Authenticator\n↻ Reload Sway\n↻ Reload Waybar\n↩ Logout\n↯ Hibernate\n🡙 Reboot\n⏻ Shutdown" | wofi -I -s $HOME/.dotfiles/wofi/style.css -c $HOME/.dotfiles/wofi/sidebar --show dmenu
)
2020-09-11 15:00:39 +00:00
fi
if [ "$res" == "⚿ Lock" ]; then
2023-01-06 19:41:31 +00:00
${WM}lock -c 000000
2020-09-11 15:00:39 +00:00
elif [ "$res" == "↩ Logout" ]; then
2023-01-06 19:41:31 +00:00
# Prevent auto-login
rm /home/jpm/.config/last_login_gui
${WM} exit
elif [ "$res" == "🖵 Toggle Displays" ]; then
2023-01-06 19:41:31 +00:00
/home/jpm/scripts/sway/toggle_outputs.sh
elif [ "$res" == "⚿ Yubico Authenticator" ]; then
2023-01-06 19:41:31 +00:00
/home/jpm/scripts/rofi/rofi-yubioath.sh
2020-09-11 15:00:39 +00:00
elif [ "$res" == "↻ Reload i3" ]; then
2023-01-06 19:41:31 +00:00
i3 reload
2020-09-11 15:00:39 +00:00
elif [ "$res" == "↹ Restart i3" ]; then
2023-01-06 19:41:31 +00:00
i3 restart
2020-09-11 15:00:39 +00:00
elif [ "$res" == "↻ Reload Sway" ]; then
2023-01-06 19:41:31 +00:00
sway reload
2023-01-07 13:16:47 +00:00
/home/jpm/scripts/distrobox/debian12/displays.sh
elif [ "$res" == "↻ Reload Waybar" ]; then
# Need to integrate with sway/displays.pl for alternative outputs
/home/jpm/scripts/distrobox/debian12/displays.sh -w
2020-09-11 15:00:39 +00:00
elif [ "$res" == "🡙 Reboot" ]; then
2023-01-06 19:41:31 +00:00
rm $SSH_AUTH_SOCK
sudo systemctl reboot -i
2020-09-11 15:00:39 +00:00
elif [ "$res" == "⏻ Shutdown" ]; then
2023-01-06 19:41:31 +00:00
rm $SSH_AUTH_SOCK
sudo systemctl poweroff -i
2020-09-11 15:00:39 +00:00
elif [ "$res" == "↯ Hibernate" ]; then
2023-01-06 19:41:31 +00:00
sudo systemctl hibernate -i
2020-09-11 15:00:39 +00:00
fi
exit 0