This repository was archived by the owner on May 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmimehandler
More file actions
executable file
·55 lines (52 loc) · 1.31 KB
/
mimehandler
File metadata and controls
executable file
·55 lines (52 loc) · 1.31 KB
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
47
48
49
50
51
52
53
54
55
#!/bin/bash
URL="$1"
notify()
{
TXT=$(echo $1 | sed -e 's|&|&|g' -e 's|<|<|g' -e 's|>|>|g')
notify-send "$TXT"
}
if [[ ( -e "$URL" ) || ($(echo "$URL" | cut -d':' -f1) == "file") ]]; then
URL=$(echo "$URL" | sed -e 's|^file://||' -e 's|%20| |g')
MIME=$(file -b --mime-type "$URL")
case $MIME in
*symlink)
URL=$(readlink "$URL")
exec $0 "$URL"
;;
audio*)
ps -U $USER -o cmd | grep ^cmus 2>/dev/null
if [ $? == 1 ]; then
xcmus &
sleep 3
fi
exec cmus-remote -q "$URL"
;;
video*|*ogg*)
exec gnome-mplayer --single_instance "$URL"
;;
image*)
exec geeqie "$URL"
;;
text*)
exec gvim --remote "$URL"
;;
*directory)
exec rox "$URL"
;;
*pdf|*dvi|*postscript)
exec evince "$URL"
;;
*)
notify "No viewer for mimetype $MIME!"
exit 1
;;
esac
elif echo $URL | grep -iq '^magnet:'; then
transmission-remote -a "$URL"
notify "Added magnet link:
$URL"
elif echo $URL | grep -iq '^http\(s\)\?://'; then
chromium "$URL"
else
notify "No handler for \"$URL\""
fi