~charles/dotfiles

ref: f2b0d150e08f193450b7f61acd36aafa1aee8e04 dotfiles/scripts/applymime.sh -rwxr-xr-x 524 bytes
f2b0d150Charles Daniels add lstodo 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

cd "$(dirname "$0")"

if [ ! -x "$(which lsdesktopf)" ] ; then
	echo "FAIL (no lsdesktopf in PATH)"
	exit 1
fi


if [ ! -x "$(which xdg-mime)" ] ; then
	echo "FAIL (no xdg-mime in PATH)"
	exit 1
fi

while read -r line ; do
	mimetype="$(echo "$line" | cut -f 1)"
	desktop="$(echo "$line" | cut -f 2)"
	echo "$line -> use $desktop for $mimetype"
	# make sure the desktop file exists
	if lsdesktopf | grep -i "$desktop" > /dev/null 2>&1 ; then
		xdg-mime default "$desktop" "$mimetype"
	fi
done < "../mimeassoc.tsv"