summaryrefslogblamecommitdiffstats
path: root/system_action
blob: 32fe1184b9d82d5a391289cfa4db883dfb5dc64f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16















                                                                                                                         
#!/bin/sh
# A dmenu wrapper script for system functions.
case "$(readlink -f /sbin/init)" in
	*systemd*) ctl='systemctl' ;;
	*) ctl='loginctl' ;;
esac

case "$(printf " lock\n display off\n logout\n sleep\n reboot\n shutdown" | dmenu -i -p 'Action: ')" in
	' lock') slock ;;
	' display off') xset dpms force off ;;
	' logout') kill -TERM "$(pgrep -u "$USER" "\bdwm$")" ;;
	' sleep') slock $ctl suspend ;;
	' reboot') $ctl reboot ;;
	' shutdown') $ctl poweroff ;;
	*) exit 1 ;;
esac