summaryrefslogtreecommitdiff
path: root/.local/bin/sysact
blob: 524907000ccaef2657e05ac843723fcd9458c6c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

# A dmenu wrapper script for system functions.

# For non-systemd init systems.
case "$(readlink -f /sbin/init)" in
	*runit*) hib="sudo -A zzz" ;;
	*openrc*) reb="sudo -A openrc-shutdown -r"; shut="sudo -A openrc-shutdown -p 0" ;;
esac

cmds="\
  lock	sudo loginctl lock-sessions
  leave dwm	killall xinit
  renew dwm	killall dwm
  hibernate	sudo loginctl hibernate
  reboot	${reb:-sudo -A reboot}
  shutdown	${shut:-sudo -A shutdown -h now}
  display off 	 xset dpms force off"

choice="$(echo "$cmds" | cut -d'	' -f 1 | dmenu)" || exit 1

`echo "$cmds" | grep "^$choice	" | cut -d '	' -f2-`