29 lines
766 B
Bash
Executable File
29 lines
766 B
Bash
Executable File
#!/bin/sh
|
|
# A dmenu wrapper script for system functions.
|
|
case "$(readlink -f /sbin/init)" in
|
|
*systemd*) ctl='systemctl' ;;
|
|
*) ctl='loginctl' ;;
|
|
esac
|
|
|
|
lock=" lock"
|
|
leave=" leave dwm"
|
|
renew=" renew dwm"
|
|
hibernate=" hibernate"
|
|
reboot=" reboot"
|
|
shutdown=" shutdown"
|
|
sleep=" sleep"
|
|
display=" display off"
|
|
|
|
case "$(printf "$lock\n$leave\n$renew\n$hibernate\n$reboot\n$shutdown\n$sleep\n$display" \
|
|
| dmenu -i -p 'Action: ')" in
|
|
$lock) slock ;;
|
|
$leave) kill -TERM "$(pgrep -u "$USER" "\bdwm$")" ;;
|
|
$renew) kill -HUP "$(pgrep -u "$USER" "\bdwm$")" ;;
|
|
$hibernate) slock $ctl hibernate ;;
|
|
$sleep) slock $ctl suspend -i ;;
|
|
$reboot) $ctl reboot -i ;;
|
|
$shutdown) $ctl poweroff -i ;;
|
|
$display) xset dpms force off ;;
|
|
*) exit 1 ;;
|
|
esac
|