#!/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 "${MENU_PROMPT}: ${svc}" "${_outp}" else notify-send -i "${ico}" -a rc -u critical -t 30000 "${MENU_PROMPT}: ${svc}" "${act}ing ${svc} failed:\n${_outp}" fi printf "%s\n" "${_outp}" done } rc-status --servicelist | menu --list=10 | tr -d '[' | tr -d ']' | handle