diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/rcmenu | 27 |
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 |