dotfiles-remastered/.config/rofi/powermenu.sh

45 lines
746 B
Bash
Raw Normal View History

2023-05-05 13:34:30 +00:00
#!/usr/bin/env sh
ROFI_CONFIG_DIR="$XDG_CONFIG_HOME/rofi/"
UPTIME="$(uptime | awk -F'( |,|:)+' '{print $6,$7",",$8,"hours,",$9,"minutes."}')"
2023-05-05 13:34:30 +00:00
SHUTDOWN=""
RESTART=""
LOCK=""
LOGOUT=""
WINDOWS=""
rofi_cmd(){
echo -e "$SHUTDOWN\n$WINDOWS\n$RESTART\n$LOGOUT\n$LOCK" | \
rofi -dmenu \
-p "Power" \
-mesg "Uptime: $UPTIME" \
-theme ${ROFI_CONFIG_DIR}/powermenu.rasi
}
selection=$(rofi_cmd)
case ${selection} in
$SHUTDOWN)
systemctl poweroff
;;
$RESTART)
systemctl reboot
;;
$LOCK)
# TODO
;;
$LOGOUT)
if [[ "$XDG_CURRENT_DESKTOP" == 'Hyprland' ]]; then
hyprctl dispatch exit
fi
;;
$WINDOWS)
boot-windows
systemctl reboot
2023-05-05 13:34:30 +00:00
;;
esac