2021-08-29 14:56:00 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Simple script to handle a DIY shutdown menu. When run you should see a bunch of options (shutdown, reboot etc.)
|
|
|
|
#
|
|
|
|
# Requirements:
|
|
|
|
# - rofi
|
|
|
|
# - systemd, but you can replace the commands for OpenRC or anything else
|
|
|
|
#
|
|
|
|
# Instructions:
|
|
|
|
current=$(wmctrl -m | grep Name | awk {'print $2'})
|
|
|
|
# - Save this file as power.sh or anything
|
|
|
|
# - Give it exec priviledge, or chmod +x /path/to/power.sh
|
|
|
|
# - Run it
|
|
|
|
chosen=$(echo -e "[Cancel]\nLogout\nShutdown\nReboot System\nEdit config\nEdit dotfiles\nEdit power menu" | rofi -dmenu -width 10 -lines 7 -i -p "Power Menu:")
|
|
|
|
# Info about some states are available here:
|
|
|
|
# https://www.freedesktop.org/software/systemd/man/systemd-sleep.conf.html#Description
|
|
|
|
|
|
|
|
if [[ $chosen = "Logout" ]]; then
|
2023-01-13 21:03:40 +00:00
|
|
|
pkill $current
|
2021-08-29 14:56:00 +00:00
|
|
|
elif [[ $chosen = "Shutdown" ]]; then
|
|
|
|
systemctl poweroff
|
|
|
|
elif [[ $chosen = "Reboot System" ]]; then
|
2023-01-13 21:03:40 +00:00
|
|
|
systemctl reboot
|
2021-08-29 14:56:00 +00:00
|
|
|
elif [[ $chosen = "Edit config" ]]; then
|
2021-08-31 18:40:22 +00:00
|
|
|
if [[ $current = "spectrwm" ]]; then
|
|
|
|
alacritty -e nvim ~/.spectrwm.conf
|
|
|
|
elif [[ $current = "awesome" ]]; then
|
|
|
|
alacritty -e nvim ~/.config/awesome/rc.lua
|
|
|
|
elif [[ $current = "leftwm" ]]; then
|
|
|
|
alacritty -e nvim ~/.config/leftwm/config.toml
|
|
|
|
fi
|
2021-08-29 14:56:00 +00:00
|
|
|
elif [[ $chosen = "Edit dotfiles" ]]; then
|
2023-01-13 21:03:40 +00:00
|
|
|
~/.config/rofi/scripts/dmenu-edit-configs.sh
|
2021-08-29 14:56:00 +00:00
|
|
|
elif [[ $chosen = "Edit power menu" ]]; then
|
2023-01-13 21:03:40 +00:00
|
|
|
alacritty -e nvim $HOME/.config/rofi/scripts/power-menu.sh
|
2021-08-29 14:56:00 +00:00
|
|
|
fi
|