abducate (1103B)
1 #!/bin/bash 2 OPTIONS="$OPTIONS -noi" 3 TERMEXEC="urxvt -e" 4 5 SERVICES=( 6 picom # name of the service is also the command 7 sxhkd 8 plumber 9 "lemonbar panel" # name is lemonbar, command is panel 10 "mousejail xpointerbarrier 0 0 50 0" 11 ) 12 13 case $1 in 14 main) 15 PROMPT="$(abducate list | sed 1q)" 16 17 SESSIONS="$(abducate list | sed -n '2,$s/\t/ /gp')" 18 for S in "${SERVICES[@]}"; do 19 NAME="$(echo $S | awk '$0=$1')" 20 RUNNING=$(echo "$SESSIONS" | awk -v name=$NAME '$NF==name{print}') 21 if [ "$RUNNING" ]; then LEAVES[${#LEAVES[@]}]="$RUNNING" 22 else LEAVES[${#LEAVES[@]}]=" ... ................... ..... $NAME"; fi 23 ACTIONS[${#ACTIONS[@]}]="child manage $NAME" 24 done;; 25 manage) 26 NAME="$2" 27 for S in "${SERVICES[@]}"; do 28 N="$(echo "$S" | awk '$0=$1')" 29 [ "$N" = "$NAME" ] && break; 30 done 31 32 COMMAND="$(echo "$S" | awk '$1="";1')" 33 [ "$COMMAND" ] || COMMAND=$NAME 34 35 PROMPT="Manage service: $NAME" 36 LEAVES=("on" "off" "toggle" "attach") 37 ACTIONS=("abducate -l $NAME start $COMMAND" 38 "abducate -l $NAME stop" 39 "abducate -l $NAME toggle $COMMAND" 40 "$TERMEXEC abducate -l $NAME attach");; 41 esac