[download]

local/bin/powermenu

   1 #!/bin/bash
   2 
   3 [[ $1 ]] &&
   4 if command -v zenity > /dev/null; then
   5     zenity --password --title="$1"
   6     exit
   7 else
   8     menu -i power -p "$1" <&-
   9     exit
  10 fi
  11 
  12 export SUDO_ASKPASS=$0
  13 s=$(printf '%s\n' Reload Restart Lock Sleep Quit Reboot Poweroff |
  14 icon -x power | menu -i power | awk '{ print $NF }')
  15 
  16 [[ $DESKTOP_SESSION ]] || export DESKTOP_SESSION=$(xprop -id $(
  17     xprop -root _NET_SUPPORTING_WM_CHECK | cut -d \# -f 2
  18 ) _NET_WM_NAME | cut -d \" -f 2 | tr A-Z a-z)
  19 
  20 case ${s,,} in
  21         lock) lock;;
  22       reload) theme -R;;
  23      restart) ~/.xprofile;;
  24        sleep) systemctl suspend;;
  25       reboot) reboot   || pkexec reboot   || sudo -A reboot;;
  26     poweroff) poweroff || pkexec poweroff || sudo -A poweroff;;
  27         quit) loginctl kill-session self  || pkill "$DESKTOP_SESSION";;
  28 esac