79 lines
1.5 KiB
Bash
Executable file
79 lines
1.5 KiB
Bash
Executable file
#!/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;;
|
|
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 ;;
|
|
*) file=$(mshow -x . ${n}); mv ${file} ${TARO_DOWNLOADS} ;;
|
|
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
|
|
}
|
|
|
|
mread() {
|
|
local META
|
|
mflag -S ${this}
|
|
local this=$(mseq $@)
|
|
local action="q"
|
|
while true; do
|
|
(mshow ${this} ; printf "\n"; mshow -t ${this}; printf "\n" ; printf "[o]pen or [s]ave attachments\n" ; printf "[r]reply, [f]orward, [q]uit\n")| less --mouse
|
|
|
|
case $? in
|
|
113) #q
|
|
break;;
|
|
102) #f
|
|
mfwd ${this};;
|
|
114) #r
|
|
mrep ${this};;
|
|
115) #s
|
|
save_attachments;;
|
|
111) #o
|
|
open_attachments;;
|
|
esac
|
|
done
|
|
}
|
|
|
|
mread $@
|