Krolyxon
Commit 59f2c95

Branches

Refs →

dotfiles-x11.localbinsysact

26 lines · 771 B · Bourne Again Shell (bash)

1#!/bin/sh
2
3export WM="dwm"
4case "$(readlink -f /sbin/init)" in
5 *systemd*) ctl='systemctl' ;;
6 *) ctl='loginctl' ;;
7esac
8
9wmpid(){ # This function is needed if there are multiple instances of the window manager.
10 tree="$(pstree -ps $$)"
11 tree="${tree#*$WM(}"
12 echo "${tree%%)*}"
13}
14
15
16case "$(printf " lock\n󰠚 leave $WM\n renew $WM\n󱣻 hibernate\n reboot\n shutdown\n sleep\n display off" | dmenu -i -l 15 -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 ;;
26esac