···11+#!/usr/bin/env bash
22+33+options=(
44+ # "swaylock"
55+ "systemctl poweroff"
66+ "systemctl reboot"
77+)
88+99+options_labels=(
1010+ # " Lock"
1111+ " Shut down"
1212+ " Reboot"
1313+)
1414+1515+set -e
1616+set -x
1717+1818+options_string=$(printf '%s\n' "${options_labels[@]}")
1919+selected_option=$(echo "$options_string" | rofi -dmenu)
2020+2121+if [[ -n $selected_option ]]; then
2222+ # Find the index of the selected option in the options_labels array
2323+ for i in "${!options_labels[@]}"; do
2424+ if [[ "${options_labels[$i]}" == "$selected_option" ]]; then
2525+ command_index=$i
2626+ break
2727+ fi
2828+ done
2929+3030+ # If a valid index is found, run the corresponding command
3131+ if [[ -n $command_index ]]; then
3232+ eval "${options[$command_index]}"
3333+ fi
3434+fi