summaryrefslogtreecommitdiffstats
path: root/system_action
diff options
context:
space:
mode:
Diffstat (limited to 'system_action')
-rwxr-xr-xsystem_action16
1 files changed, 16 insertions, 0 deletions
diff --git a/system_action b/system_action
new file mode 100755
index 0000000..32fe118
--- /dev/null
+++ b/system_action
@@ -0,0 +1,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