-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path.mcohandler
executable file
·47 lines (42 loc) · 1.07 KB
/
.mcohandler
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
41
42
43
44
45
46
#!/bin/sh -e
# This is my file handler for mailcap_open, it will:
# - open m3u files with video player
# - transparently handle gpg files as if they weren't encrypted
# - tries to handle image/video URLs with the right programs
# - open all other URLs in a browser
#
mailcap_open() {
command ${I2P:+i2proxychains} ${TOR:+torsocks} mailcap_open "$@"
}
unset -v I2P TOR
case "$1" in
*://*.i2p/*|*://*.i2p) I2P=1 ;;
*://*.onion/*|*://*.onion) TOR=1 ;;
esac
# prevent nesting
case "$LD_PRELOAD" in
*libproxychains*.so) unset -v I2P ;;
*libtorsocks*.so) unset -v TOR ;;
esac
case "$1" in
*://*.png|*://*.jpg|*://*.jpeg|*://*.gif|*://*.tiff)
export MIMETYPE='image/generic'; export MCO_HANDLER=':';
mailcap_open "$1"
exit 1
;;
*.m3u|*://*.mkv|*://*.mp4|*://*.webm|*://youtu*|*://www.youtu*)
export MIMETYPE='video/generic'; export MCO_HANDLER=':';
mailcap_open "$1"
exit 1
;;
*://*)
export MIMETYPE='text/html'; export MCO_HANDLER=':';
mailcap_open "$1"
exit 1
;;
*.gpg)
export MCO_NEEDSTERMINAL=1; export EDITOR='mailcap_open';
gpgedit "$1"
exit 1
;;
esac