X-Git-Url: https://git.madduck.net/etc/mutt.git/blobdiff_plain/c6f18b8c7e3aae4672c711b159baec611a3358f5..a83d50d5a64488deb3796bbd0ca0a03b0516cc77:/.mutt/bgrun?ds=sidebyside diff --git a/.mutt/bgrun b/.mutt/bgrun index f1ad14c..ad432df 100755 --- a/.mutt/bgrun +++ b/.mutt/bgrun @@ -10,12 +10,9 @@ TEMPRUNDIR=.tempdir-run.d cleanup() { if [ -d $TEMPRUNDIR ]; then local TEMPDIR; TEMPDIR="$PWD" - echo Cleaning up tempdir $TEMPDIR… >> output.stderr notify_output cd / rm -rf "$TEMPDIR" - else - notify_output fi trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15 } @@ -80,13 +77,13 @@ notify_output() { } guess_extension() { - python -c "import mimetypes; print(mimetypes.guess_extension('$1'))" + python3 -c "import mimetypes; print(mimetypes.guess_extension('$1'))" } get_file() { local t if [ -z "$1" ]; then - t=$(TMPDIR="$PWD" tempfile -s $(guess_extension "$MIMETYPE")) + t=$(mktemp -p "$PWD" tmp.XXXXXXXXXX.$(guess_extension "$MIMETYPE")) cat > "$t" echo "$t" else @@ -141,7 +138,7 @@ case "$SELF" in ( ts=$(($(date +%s) + $DELAY)) launch_viewer "$FILE" "$MIMETYPE" - while [ $(date +%s) -lt $ts ]; do sleep $DELAY; done + while [ $(date +%s) -lt $ts ]; do sleep 1; done cleanup ) & trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15 @@ -174,9 +171,8 @@ case "$SELF" in (launch_viewer "$FILE" "$MIMETYPE") & ( while [ $(($(stat -c%X "$FILE") + $DELAY)) -gt $(date +%s) ]; do - sleep $DELAY + sleep 1 done - echo Cleaning up $TMPDIR… > $TMPDIR/output.stderr cleanup ) & trap - 1 2 3 4 5 6 7 8 10 11 12 13 14 15