From a1f51e588e7d48ca28b45304c0dc53fd806aa391 Mon Sep 17 00:00:00 2001 From: mxmehl Date: Wed, 2 Aug 2017 12:00:46 +0200 Subject: [PATCH] add attachment saving script which isn't perfect yet but does its job --- astroid/config | 2 +- astroid/scripts/attachment-saver.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 astroid/scripts/attachment-saver.sh 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