diff options
author | zachir <zachir@librem.one> | 2023-05-23 15:01:20 -0500 |
---|---|---|
committer | zachir <zachir@librem.one> | 2023-05-23 15:01:20 -0500 |
commit | 32d82fba2c762efccb356c2a0b3e408068cc6e03 (patch) | |
tree | ddda5e6f41956e625eb40a2191309b5542ee5c4c /t | |
parent | f3e17b53a3351fa6f3c090a76c7680084d1d2eac (diff) |
Total reorganization, we're moving on from X
Diffstat (limited to 't')
-rwxr-xr-x | t | 38 |
1 files changed, 21 insertions, 17 deletions
@@ -1,27 +1,31 @@ #!/bin/sh -unset SPAWN +unset KILL SPAWN -while getopts "t:r:a:" o; do case "${o}" in +MODE="t" + +while getopts "-tr" o; do case "${o}" in + t) MODE="t" ;; + r) MODE="r" ;; + -) break ;; +esac done + +SPAWN="$(echo "$@" | sed 's/^.*-[-tr] //')" +KILL="$(echo $SPAWN | cut -d' ' -f1)" + +[ -z "${MODE}" -o -z "$SPAWN" ] && exit +case "${MODE}" in t) - if pgrep -Uzachir -x "$OPTARG" >/dev/null 2>&1; then - pkill -Uzachir -x "$OPTARG" - exit + if pgrep -x "$KILL"; then + killall "$KILL" 2>&1 >/dev/null else - SPAWN="$OPTARG" + $SPAWN & fi ;; r) - if pgrep -Uzachir -x "$OPTARG" >/dev/null 2>&1; then - pkill -Uzachir -x "$OPTARG" - fi - SPAWN="$OPTARG" - ;; - a) - ARGS="$ARGS$OPTARG " + killall "$KILL" 2>&1 >/dev/null + sleep 0.1 + $SPAWN & ;; -esac done - -sleep 0.1 -[ -n "$SPAWN" ] && exec "$SPAWN" $ARGS & +esac |