-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmail-preview
executable file
·40 lines (35 loc) · 1.1 KB
/
mail-preview
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
# shellcheck source=/dev/null
. ~/.dotfiles/linux/mail-query.sh
browser="firefox"
window_width="#window { width: 60%; }"
mail=$(mu find \
--sortfield=date \
--reverse \
--fields='f s l i' \
"${query:?}" 2>/dev/null)
selection=$(echo "${mail}" | rofi -theme-str "${window_width}" -kb-custom-1 'Alt+c' -kb-custom-2 'Alt+v' -dpi 1 -dmenu -p "Preview message:")
rofi_code=$?
file_path=$(echo "${selection}" | cut -f 3)
select_style() {
file=$(~/bin/mailpreview-cli "${file_path}" "${1}")
file_code=$?
if [ "${file_code}" -eq 0 ]; then
"${browser}" "file://${file}"
fi
}
case ${rofi_code} in
11)
echo "${file_path}" | xclip -selection clipboard;;
10)
id=$(echo "${selection}" \
| cut -f 4 \
| tr -d '[:space:]')
link="mu4e:msgid:${id}"
emacsclient -e "(org-link-open-from-string \"${link}\")";;
0)
format=$(printf "text/plain\ntext/html" | rofi -theme-str "${window_width}" -dpi 1 -dmenu -p "Format:")
select_style "${format}";;
*)
exit 0;
esac