This repository has been archived on 2023-01-25. You can view files and clone it. You cannot open issues or pull requests or push a commit.
2017-08-02 12:00:46 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
#
|
2017-08-23 11:35:53 +02:00
|
|
|
# prevents astroid to delete an attachment file immediately
|
|
|
|
|
# but instead copies it to a separate directory and preserves it
|
|
|
|
|
#
|
2017-08-02 12:00:46 +02:00
|
|
|
# based on https://github.com/astroidmail/astroid/issues/339#issuecomment-300491869
|
|
|
|
|
|
|
|
|
|
cachedir=~/.cache/astroid-attachments
|
2017-11-14 12:24:25 +01:00
|
|
|
attachment=$(echo "$1" | sed -E "s|.*astroid/[a-zA-Z0-9]*?-||")
|
2017-08-02 12:00:46 +02:00
|
|
|
|
2017-08-23 11:35:53 +02:00
|
|
|
touch $cachedir/token."$attachment"
|
2017-08-02 12:00:46 +02:00
|
|
|
|
|
|
|
|
if [ ! -e ${cachedir} ]; then
|
|
|
|
|
mkdir -p ${cachedir}
|
|
|
|
|
fi
|
|
|
|
|
|
2017-08-23 11:35:53 +02:00
|
|
|
mv "$1" ~/.cache/astroid-attachments/"$attachment"
|
2017-08-02 12:00:46 +02:00
|
|
|
|
|
|
|
|
inotifywait -e close "$1" &
|
|
|
|
|
ip=$!
|
|
|
|
|
|
|
|
|
|
# open file (you can replace this with xdg-open)
|
|
|
|
|
xdg-open "$cachedir/$attachment"
|
|
|
|
|
|
2017-08-23 11:35:53 +02:00
|
|
|
while inotifywait -r -e close $cachedir/"$attachment"; do
|
|
|
|
|
rm $cachedir/token."$attachment" # || rm $cachedir/"$attachment"
|
|
|
|
|
done
|