hypr/scripts/power-menu.sh
Maximilian Wagner 665351aaac new setup
2025-06-17 14:24:21 +02:00

28 lines
647 B
Bash
Executable File

#!/bin/bash
dmenu_command=(wofi -dmenu -p "Power Menu" -i)
# Define menu options and corresponding actions
options=(
"Lock"
"Logout"
"Shutdown"
"Reboot"
)
# Create associative array mapping text to actions
declare -A actions
actions["Lock"]="sleep 0.2 && hyprlock"
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