#!/bin/sh set -e [ -n "$DEBUG" ] && set -x export MENU_PROMPT="󰑮 rc" ico=/usr/share/icons/mdi/scalable/run-fast.svg 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 -i "${ico}" -a rc rc "${_outp}" else notify-send -i "${ico}" -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