Files
hypr/scripts/power-menu.sh
Maximilian Wagner e41b64c0ab added suspend action
2025-12-29 23:21:50 +01:00

30 lines
711 B
Bash
Executable File

#!/bin/bash
dmenu_command=(wofi -dmenu -p "Power Menu" -i)
# Define menu options and corresponding actions
options=(
"Lock"
"Suspend"
"Logout"
"Shutdown"
"Reboot"
)
# Create associative array mapping text to actions
declare -A actions
actions["Lock"]="sleep 0.2 && hyprlock"
actions["Suspend"]="sleep 0.2 && systemctl suspend"
actions["Logout"]="hyprctl dispatch exit"
actions["Shutdown"]="systemctl poweroff"
actions["Reboot"]="systemctl reboot"
# Prompt user using wofi in dmenu mode
choice=$(printf '%s\n' "${options[@]}" | "${dmenu_command[@]}")
# Run the corresponding command if valid choice was made
if [[ -n "$choice" && -n "${actions[$choice]}" ]]; then
eval "${actions[$choice]}"
fi