2023-03-24 05:36:20 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
mhandle() {
|
|
|
|
case $2 in
|
|
|
|
text/html)
|
|
|
|
cp $1 ${1}.html
|
|
|
|
netsurf ${1}.html
|
|
|
|
rm ${1}.html;;
|
|
|
|
image/*)
|
|
|
|
qiv $1;;
|
|
|
|
audio/*|video/*)
|
|
|
|
mpv $1;;
|
|
|
|
pgp/encrypted)
|
|
|
|
gpg --decrypt $1;;
|
|
|
|
application/vnd*)
|
|
|
|
libreoffice $1;;
|
|
|
|
application/pdf)
|
|
|
|
zathura $1;;
|
2024-05-05 17:09:16 +00:00
|
|
|
*)
|
|
|
|
less $1;;
|
2023-03-24 05:36:20 +00:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
save_attachments() {
|
|
|
|
while true; do
|
|
|
|
printf "\n"
|
|
|
|
mshow -t
|
|
|
|
printf "\n"
|
|
|
|
|
|
|
|
printf "select an attachment to save: "
|
|
|
|
read n
|
|
|
|
case ${n} in
|
|
|
|
''|*[!0-9]*) return ;;
|
2023-03-28 04:54:20 +00:00
|
|
|
*) file=$(mshow -x . ${n}); mv "${file}" ${TARO_DOWNLOADS} ;;
|
2023-03-24 05:36:20 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
open_attachments() {
|
|
|
|
while true; do
|
|
|
|
printf "\n"
|
|
|
|
mshow -t
|
|
|
|
printf "\n"
|
|
|
|
|
|
|
|
printf "select an attachment to open: "
|
|
|
|
read n
|
|
|
|
case $n in
|
|
|
|
''|*[!0-9]*) return ;;
|
|
|
|
*) attachment=$(mktemp)
|
|
|
|
mshow -O . ${n} > ${attachment}
|
|
|
|
mimetype=$(mshow -t | grep ${n}: | awk '{print $2}')
|
|
|
|
mhandle ${attachment} ${mimetype}
|
|
|
|
rm ${attachment};;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-03-25 17:25:50 +00:00
|
|
|
keep_track_of_mailfile() {
|
|
|
|
orig=$1
|
2024-05-05 17:09:16 +00:00
|
|
|
stamp=${orig%,*}
|
|
|
|
new=$(echo ${stamp}*)
|
2023-03-25 17:25:50 +00:00
|
|
|
printf "${new}"
|
|
|
|
}
|
|
|
|
|
2023-03-24 05:36:20 +00:00
|
|
|
mread() {
|
|
|
|
local this=$(mseq $@)
|
2023-03-25 17:25:50 +00:00
|
|
|
mflag -S ${this}
|
2023-03-24 05:36:20 +00:00
|
|
|
while true; do
|
2023-03-25 17:25:50 +00:00
|
|
|
this=$(keep_track_of_mailfile ${this})
|
2024-05-05 17:09:16 +00:00
|
|
|
if [ ! -e "${this}" ]; then
|
2023-03-25 17:25:50 +00:00
|
|
|
printf "Looks like this email was refiled... Press Enter to close this window. "
|
2024-05-05 17:09:16 +00:00
|
|
|
read r
|
2023-03-25 17:25:50 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
(mshow ${this} ; printf "\n"; mshow -t ${this})| less --mouse -Ps"[o]pen or [s]ave attachments, [r]reply, [f]orward, [q]uit"$
|
2023-03-24 05:36:20 +00:00
|
|
|
|
|
|
|
case $? in
|
|
|
|
113) #q
|
|
|
|
break;;
|
|
|
|
102) #f
|
|
|
|
mfwd ${this};;
|
|
|
|
114) #r
|
|
|
|
mrep ${this};;
|
|
|
|
115) #s
|
|
|
|
save_attachments;;
|
|
|
|
111) #o
|
|
|
|
open_attachments;;
|
|
|
|
esac
|
2023-03-25 17:25:50 +00:00
|
|
|
|
2023-03-24 05:36:20 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
mread $@
|