#!/bin/bash ################################################### ## shut down pc and break instantwm restart loop ## ################################################### # multiple instances would overlap if [ "$(pgrep instantshutdown | wc -l)" -gt 2 ]; then pgrep instantshutdown | wc -l echo "instantshutdown already running" exit fi answer="$(echo 'cancel shutdown logout reboot lock screen suspend restart wm' | instantmenu -l 10 -w -1 -c -n -F -p 'shutdown menu' -q 'select')" # if there are apps open, ask for confirmation zconfirm() { if wmctrl -l | grep -q '..'; then echo "running applications found" if imenu -c "there are apps running, sure you want to $1?"; then echo "yes" return 0 else echo "no" exit fi else echo "no running applications found" fi } prepareshutdown(){ # save current brightness touch /tmp/shuttingdown if CURBRIGHT="$(/usr/share/instantassist/utils/b.sh g)" then iconf savebright "$CURBRIGHT" fi rm /tmp/instantosrunning # these keep causing stop jobs pkill -f clipnotify pkill -f clipmenud } case "$answer" in shut*) zconfirm "shutdown" prepareshutdown sleep 0.4 shutdown now ;; reb*) zconfirm "reboot" prepareshutdown sleep 0.4 reboot ;; log*) zconfirm "sign out" rm /tmp/instantosrunning sleep 0.4 kill -9 -1 ;; loc*) ilock ;; sus*) systemctl suspend ilock ;; res*) pkill instantwm ;; *) echo "canceled" ;; esac