summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2021-04-22 13:24:09 +0200
committerRobert Günzler <r@gnzler.io>2021-04-26 02:09:48 +0200
commita3a79725782c0ca6ef177eaa7942c0a9d2bf209c (patch)
treec4feb789c32a89ecc074efe04c2f1d0679914f79 /bin
parenta1b25bfa624e0cb540c74d3816d4a69be3bc8f0d (diff)
Add bin/rcmenu, bemenu-based tool to start/stop openrc services
Diffstat (limited to 'bin')
-rwxr-xr-xbin/rcmenu27
1 files changed, 27 insertions, 0 deletions
diff --git a/bin/rcmenu b/bin/rcmenu
new file mode 100755
index 0000000..950c82c
--- /dev/null
+++ b/bin/rcmenu
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+set -e
+[ -n "$DEBUG" ] && set -x
+
+export MENU_PROMPT="> rc"
+
+handle() {
+	while read -r line; do
+		svc=$(printf "%s" "${line}" | awk '{print $1}')
+		mode=$(printf "%s" "${line}" | awk '{print $2}')
+		act=restart
+		[ "${mode}" = "started" ] && act=stop
+		_outp=$(doas rc-service "${svc}" "${act}")
+		if [ $? = 0 ]; then
+			notify-send -a rc rc "${_outp}"
+		else
+			notify-send -a rc -u critical -t 30000 rc "${act}ing ${svc} failed:\n<i>${_outp}</i>"
+		fi
+		printf "%s\n" "${_outp}"
+	done
+}
+
+rc-status --servicelist \
+	| awk '{printf "%25s\t%s\n", $1, $3}' \
+	| menu --list=10 \
+	| handle