summaryrefslogtreecommitdiff
path: root/misc/mime
blob: 207037649fc2b30d61b50ac4d38c396c8f1a054c (plain)
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
#!/bin/sh
cachedir="${XDG_CACHE_HOME:-$HOME/.cache}/mimewiz"
types="`grep -v '#'`"<< TYPES
application
audio
font
#example
image
#message
#model
#multipart
text
video
TYPES
typesrc="https://www.iana.org/assignments/media-types"

#dlcsv() { curl -sS -C - -e "$typesrc"  "$typesrc" > "$typefile" || exit; }
dlcsv() { curl -sS -C - -o "$2" "$1" || exit; }

# Download all media type csv's if they're not avaliable
mkdir -p "$cachedir"
for type in $types; do
	typefile="$cachedir/$type.csv"
	[ -e "$typefile" ] || dlcsv "$typesrc/$type.csv" "$typefile"
	#[ "$2" = "$type" ] && mimetype="`cut -d',' -f2 $typefile`" && break
done

#[ -n "$mimetype" ] && xdg-mime default $application.desktop $mimetype

# Choose mimetype:
types="$types\npdf\nspreadsheet ms-excel\nwordprocessing ms-word\npresentation ms-powerpoint\ndrawing\nzip gzip"
echo "$types" | nl -s': '

echo "$types" | head -7 | tail -1

# Choose subtype
#cut -d',' -f1 "$cachedir/application.csv" | grep drawing | nl -s': ' | column

# Choose program
ls /usr/share/applications | sed 's/\.desktop//' | nl -s': ' | column


#cut -d',' -f1 "$cachedir/image.csv" | nl -s': ' | column
cut -d',' -f2 "$cachedir/image.csv"

#jcho "$types" | while read type; do
#done