blob: be8de9cc06f2c47ad37681145ae19f62f0f8d628 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
DEFAULT_FILE='file' # .png gets added automatically
#INPUT_FILE=test-globs
#INPUT_FILE=/usr/share/mime/generic-icons < /usr/share/mime/globs
INPUT_FILE=$1
OUT_PATH="../"
MAX_LINES=`cat $INPUT_FILE | wc -l`
CUR_LINE=0
IFS=':'
while read A B
do
if [[ "$A" == "#"* ]]; then continue; fi
MIME=$A
FILE=${A/\//-}
TEXT=${B/\*\./}
((CUR_LINE++))
printf "[%-4d/%-4d] checking for %s\n" "$CUR_LINE" "$MAX_LINES" "$FILE.png"
if [[ -f "default/$FILE.png" ]]; then
echo "using default."
cp "default/$FILE.png" "$OUT_PATH/$FILE.png"
else
FIND=$FILE
while [[ 1 ]]
do
# printf "%s\n" $FIND
if [[ -f "default/$FIND.png" ]]; then break; fi
if [[ "$FIND" == "${FIND%-*}" ]]; then FIND="$DEFAULT_FILE"; break; fi
FIND=${FIND%-*}
done
# create default file... just in case there is no desktop file...
cp "default/$FIND.png" "$OUT_PATH/$FILE.png"
DESKTOP=`xdg-mime query default $MIME`
if [[ -f /usr/share/applications/$DESKTOP ]]; then
ICONTEXT=`grep -o 'Icon=.*' /usr/share/applications/$DESKTOP`
APPICON=`find ../../ /usr/share/icons/Adwaita/scalable /usr/share/icons/hicolor/scalable -path '*apps*' -name "${ICONTEXT/Icon=/}*" -type f -print -quit`
printf "%-12s%s\t%s\t%s\t%s\n" "" $MIME $DESKTOP $FIND $APPICON
if [[ "$APPICON" ]]; then
convert \
"default/$FIND.png" \( -density 400 $APPICON -resize 256 \) \
-gravity north -geometry +0+20 \
-compose darken -composite $OUT_PATH/$FILE.png
fi
fi
fi
mogrify "$OUT_PATH/$FILE.png" \
-gravity northwest -pointsize 60 -rotate 90 \
-stroke '#444' -strokewidth 2 -annotate 0 "${FILE##*-}" \
-fill '#ff0' -annotate 0 "${FILE##*-}" \
-rotate -90 -resize 256 $OUT_PATH/$FILE.png
done < $INPUT_FILE
|