Recently Written · git

dmenu-scripts

Ask for things

git clone https://github.com/equwal/dmenu-scripts

Log | Files | Refs


dsysact (787 bytes)

1 #!/bin/sh
2 
3 # A dmenu wrapper script for system functions.
4 export WM="dwm"
5 case "$(readlink -f /sbin/init)" in
6 	*systemd*) ctl='systemctl' ;;
7 	*) ctl='loginctl' ;;
8 esac
9 
10 wmpid(){ # This function is needed if there are multiple instances of the window manager.
11 	tree="$(pstree -ps $$)"
12 	tree="${tree#*$WM(}"
13 	echo "${tree%%)*}"
14 }
15 
16 case "$(printf "🔒 lock\n🚪 leave $WM\n♻️ renew $WM\n🐻 hibernate\n🔃 reboot\n🖥️shutdown\n💤 sleep\n📺 display off" | dmenu -i -p 'Action: ')" in
17 	'lock') slock ;;
18 	"leave $WM") kill -TERM "$(wmpid)" ;;
19 	"renew $WM") kill -HUP "$(wmpid)" ;;
20 	'hibernate') slock $ctl hibernate -i ;;
21 	'sleep') slock $ctl suspend -i ;;
22 	'reboot') $ctl reboot -i ;;
23 	'shutdown') $ctl poweroff -i ;;
24 	'display off') xset dpms force off ;;
25 	*) exit 1 ;;
26 esac