hysteria

ii wrapper script
git clone git://git.2f30.org/hysteria
Log | Files | Refs | README | LICENSE

commit 9dafde08c0f8b2e232e77c60199ff03b218c6b57
parent ac8e6845d4d8b237241df25cb36fc9dc43231430
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun,  9 Nov 2014 16:30:07 +0000

kill window if "in" file doesn't exist anymore

Diffstat:
Mhysteria-monitor | 32+++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/hysteria-monitor b/hysteria-monitor @@ -10,27 +10,33 @@ else fi while :; do - cd "$ircdir" && break + cd "$ircdir" 2> /dev/null && break sleep 1 done while :; do - for n in $(find . -name "in" | sort -r 2>/dev/null); do - title=$(printf '%s' "$n" | awk -F/ '{ \ - if (NF == 4) \ - print $2":"$3; \ - else if (NF == 3) \ - print $2}') - found=0 + for chan in $(find . -type d | sort 2>/dev/null); do + h=$(basename $(dirname "$chan")) + c=$(basename "$chan") + NDIR="$(readlink -f $chan)" + INFILE="${NDIR}/in" + OUTFILE="${NDIR}/out" + title="$h:$c" + if test x"$h" = x"."; then + title="$c" + fi + # find window. + foundwin=0 for t in $(tmux list-windows -F '#W'); do if test "$t" = "$title"; then - found=1 + foundwin=1 break fi done - if test $found -eq 0; then - INFILE="$(readlink -f $n)" - NDIR="$(dirname ${INFILE})" - OUTFILE="${NDIR}/out" + # kill window. + if test $foundwin -eq 1 && test -e "${OUTFILE}" && ! test -e "${INFILE}"; then + tmux kill-window -t ":${title}" + elif test $foundwin -eq 0 && test -e "${INFILE}"; then + # window not found, create it. CHAN="$(basename ${NDIR})" # default inputcmd if not set in config. if test x"${inputcmd}" = x""; then