~charles/dotfiles

ref: e5640a548afb6aaae4fac8164e93c8727d2c1f90 dotfiles/applymime.sh -rwxr-xr-x 523 bytes
e5640a54Charles Daniels setup albert on Linux 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"