diff --git a/astroid/config b/astroid/config index d52dba1..7adafab 100644 --- a/astroid/config +++ b/astroid/config @@ -65,7 +65,7 @@ "interval": "240" }, "attachment": { - "external_open_cmd": "xdg-open" + "external_open_cmd": "/home/max/.config/astroid/scripts/attachment-saver.sh" }, "thread_view": { "open_html_part_external": "false", diff --git a/astroid/scripts/attachment-saver.sh b/astroid/scripts/attachment-saver.sh new file mode 100755 index 0000000..be0ea87 --- /dev/null +++ b/astroid/scripts/attachment-saver.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# based on https://github.com/astroidmail/astroid/issues/339#issuecomment-300491869 + +cachedir=~/.cache/astroid-attachments +attachment=$(echo $1 | sed "s#.*astroid/##") + +touch $cachedir/token.$attachment + +if [ ! -e ${cachedir} ]; then + mkdir -p ${cachedir} +fi + +mv $1 ~/.cache/astroid-attachments/ + +inotifywait -e close "$1" & +ip=$! + +# open file (you can replace this with xdg-open) +xdg-open "$cachedir/$attachment" + +while inotifywait -r -e close $cachedir/$attachment; do rm $cachedir/token.$attachment || rm $cachedir/$attachment; done