#!/bin/bash #LOCKSCRIPT="i3lock-extra -m pixelize" FG_COLOR="#d7d7d7" BG_COLOR="#15325A" SF_COLOR="#3555d7" SB_COLOR="#6484c7" color="-bg $BG_COLOR -fg $FG_COLOR -hlfg $SF_COLOR -hlbg $SB_COLOR -bw 0" # menu defined as an associative array typeset -A menu # Menu with keys/commands menu=( [Shutdown]="systemctl poweroff" [Reboot]="systemctl reboot" [Hibernate]="systemctl hibernate" [Suspend]="systemctl suspend" [Halt]="systemctl halt" [Lock]="i3lock --color=${BG_COLOR}" [Logout]="i3-msg exit" [Cancel]="Cancel" ) # Menu entries that may trigger a confirmation message menu_confirm="Shutdown Reboot Hibernate Suspend Halt Logout" launcher="rofi -dmenu -hide-scrollbar -width 10" launcher_opt="-i -yoffset 23 -location 3 $color" selection=$(printf '%s\n' ${!menu[@]} | sort | eval '$launcher $launcher_opt -font "Hack-Regular 12" -lines 8') if [ $selection == "Cancel" ] || [ -z $selection ]; then exit 1 else if [[ ${menu_confirm[*]} =~ $selection ]]; then confirm=$(printf 'Yes\nNo\n' | eval '$launcher $launcher_opt -l 2 -font "Hack-Regular 12"') if [[ $confirm == 'Yes' ]]; then i3-msg -q "exec ${menu[${selection}]}" fi else i3-msg -q "exec ${menu[${selection}]}" fi fi