From a3a79725782c0ca6ef177eaa7942c0a9d2bf209c Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Thu, 22 Apr 2021 13:24:09 +0200 Subject: Add bin/rcmenu, bemenu-based tool to start/stop openrc services --- bin/rcmenu | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 bin/rcmenu (limited to 'bin') 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${_outp}" + fi + printf "%s\n" "${_outp}" + done +} + +rc-status --servicelist \ + | awk '{printf "%25s\t%s\n", $1, $3}' \ + | menu --list=10 \ + | handle -- cgit 1.4.1