summaryrefslogtreecommitdiff
path: root/bin/openfile
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2020-11-19 09:20:37 -0500
committerLuke Smith <luke@lukesmith.xyz>2020-11-19 09:20:37 -0500
commit50c197ac632a35f3d8d012596f872a7854475030 (patch)
tree59afef77f15407723ede0259917b0ecabe0beee0 /bin/openfile
parent9c467bf4d26648baca690d81dda978ed14170cfc (diff)
attachment fix; documentation fixes
Diffstat (limited to 'bin/openfile')
-rwxr-xr-xbin/openfile13
1 files changed, 7 insertions, 6 deletions
diff --git a/bin/openfile b/bin/openfile
index f6668dc..cf3c6c3 100755
--- a/bin/openfile
+++ b/bin/openfile
@@ -1,9 +1,10 @@
#!/bin/sh
# Helps open a file with xdg-open from mutt in a external program without weird side effects.
-[ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid xdg-open"
-mkdir -p "/tmp/$USER-mutt-tmp"
-file="/tmp/$USER-mutt-tmp/$(basename "$1")"
-rm -f "$file"
-cp "$1" "$file"
-$opener "$file" >/dev/null 2>&1 &
+tempdir="${XDG_CACHE_HOME:-$HOME/.cache}/mutt-wizard/files"
+file="$tempdir/$(basename "$1")"
+[ "$(uname)" = "Darwin" ] && opener="open" || opener="setsid -f xdg-open"
+mkdir -p "$tempdir"
+cp -f "$1" "$file"
+$opener "$file" >/dev/null 2>&1
+find "${tempdir:?}" -mtime +1 -type f -delete