-
Notifications
You must be signed in to change notification settings - Fork 4
/
build_theme
executable file
·153 lines (150 loc) · 4.87 KB
/
build_theme
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
# build an icon theme from svg source - a bit hard coded :P
# (c) Michael Amadio, 2016,2019 - GPLv2
[ -f ./build.conf ] && . ./build.conf
[ -z "$NAME" ] && NAME=Generic
[ -z "$COMMENT" ] && COMMENT="An Icon Theme"
THEME="$NAME"
echo "Please wait. Processing $THEME ..."
[ -d "$THEME" ] && rm -r "$THEME"
TMP0=$(mktemp -p /tmp icn.XXXXXXXXX)
TMP1=$(mktemp -p /tmp fix.XXXXXXXXX)
(
cd icons
# find each icon
while read -r line;do
[ "${line:0:1}" = "#" ] && continue
[ -z "$line" ] && continue
# process, construct each icon
while read -r a b c; do
[ -d "../${THEME}/${a}" ] || mkdir -p "../${THEME}/${a}"
SIZE=${a%/*}
[ "$SIZE" = 'scalable' ] && SIZE=256 # fix scalable
while read -r ent;do
[ -z "$ent" ] && continue # skip blank lines
if [ "${ent:0:4}" = '<svg' ];then
if echo "$ent" | grep -q 'xlink';then
printf "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" height=\"${SIZE}px\" width=\"${SIZE}px\" viewBox=\"$VIEWBOX\">\n" >> "../${THEME}/${a}/${b}"
else
printf "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"${SIZE}px\" width=\"${SIZE}px\" viewBox=\"$VIEWBOX\">\n" >> "../${THEME}/${a}/${b}"
fi
elif [ "${ent:0:5}" = '<?xml' -o "${ent:0:6}" = '</svg>' ];then
printf "%s\n" "${ent}" >> "../${THEME}/${a}/${b}"
else
printf " %s\n" "${ent}" >> "../${THEME}/${a}/${b}"
fi
done <<< "$(cat $b)"
# link(s) to icon if needed
for link in `echo "$c"`;do
[ -z "$b" ] && continue
(cd "../${THEME}/${a}"; ln -sf "$b" "$link")
done
done <<< "$line"
done < ../theme.conf
)
# constuct the index.theme
echo '[Icon Theme]' > "${THEME}"/index.theme
echo "Name=${THEME}" >> "${THEME}"/index.theme
echo "Inherits=hicolor" >> "${THEME}"/index.theme
echo "Comment=$COMMENT" >> "${THEME}"/index.theme
echo -n "Directories=" >> "${THEME}"/index.theme
(cd "${THEME}"; find ./16 ./22 ./24 ./32 ./48 ./64 ./scalable -mindepth 1 -type d) > $TMP0
while read -r w;do
echo -n "${w#*/}," >> $TMP1
done < $TMP0
cat "$TMP1" | sed 's/,$//' >> "${THEME}"/index.theme
rm $TMP1
echo "" >> "${THEME}"/index.theme
while read -r y;do
yy=${y#*/}
py=${yy#*/}
echo "" >> "${THEME}"/index.theme
case $yy in
scalable*)
echo "[${yy}]" >> "${THEME}"/index.theme
echo "Size=256" >> "${THEME}"/index.theme
echo "Context=${py^}" >> "${THEME}"/index.theme #first char upper
echo "Type=Scalable" >> "${THEME}"/index.theme
echo "MinSize=8" >> "${THEME}"/index.theme
echo "MaxSize=512" >> "${THEME}"/index.theme
;;
*)
echo "[${yy}]" >> "${THEME}"/index.theme
SIZE=${yy%/*}
echo "Size=${SIZE}" >> "${THEME}"/index.theme
echo "Context=${py^}" >> "${THEME}"/index.theme
echo "Type=fixed" >> "${THEME}"/index.theme
;;
esac
done < $TMP0
rm $TMP0
# move to dir structure
pkg=$PKG # build.conf
mkdir -p ${pkg}/usr/share/icons
cp -arf "$THEME" ${pkg}/usr/share/icons
# build rox desktop theme
if [ "$PUPPY" = 'true' ]; then
[ -n "$ROXTHEME" ] && roxtheme=$ROXTHEME || roxtheme=${THEME/ /} # replace spaces
mkdir -p ${pkg}/usr/local/lib/X11/themes/${roxtheme}
( cd $pkg
echo -n "Constructing ${roxtheme} ROX desktop icon theme... "
TGT_DIR=usr/local/lib/X11/themes/${roxtheme}
SRC_DIR="usr/share/icons/${THEME}/48"
mkdir -p ${TGT_DIR}
for m in application-x-compressed.svg application-pet.svg;do
case $m in
*compressed*)t=archive.svg;;
*pet*)t=pet.svg;;
esac
cp -af "${SRC_DIR}/mimetypes/$m" ${TGT_DIR}/${t}
done
for a in internet.svg chat.svg paint.svg edit.svg libreoffice-calc.svg libreoffice-draw.svg libreoffice-writer.svg calendar.svg terminal.svg mail.svg network.svg module.svg screen_lock.svg multimedia.svg;do
case $a in
internet*)u=www.svg;;
*calc*)u=spread.svg;;
*draw*)u=draw.svg;;
*writer*)u=word.svg;;
calendar*)u=date.svg;;
terminal*)u=console.svg;;
mail*)u=email.svg;;
network*)u=connect.svg;;
module*)u=utility.svg;;
screen_lock*)u=lock-screen.svg;;
chat*|paint*|edit*|multimedia*)u=$a;;
esac
cp -af "${SRC_DIR}/apps/$a" ${TGT_DIR}/${u}
done
for p in desktop.svg directory.svg trash_full.svg trash_empty.svg;do
case $p in
dir*)v=folder.svg;;
desktop*)v=x.svg;;
trash_empty*)v=trashcan_empty.svg;;
trash_full*)v=trashcan_full.svg;;
esac
cp -af "${SRC_DIR}/places/$p" ${TGT_DIR}/${v}
done
for d in cdrom.svg floppy.svg harddisk.svg disk_usb.svg computer.svg flashcard.svg;do
case $d in
cdrom*)w=optical.svg;;
harddisk*)w=drive.svg;;
*usb*)w=usbdrv.svg;;
computer*)w=pc.svg;;
flashcard*)w=card.svg;;
*)w=$d;;
esac
cp -af "${SRC_DIR}/devices/$d" ${TGT_DIR}/${w}
done
for x in save.svg home.svg shutdown.svg;do
cp -af "${SRC_DIR}/actions/$x" ${TGT_DIR}/${x}
done
for c in game.svg preferences.svg dialog-info.svg;do
case $c in
game*)y=games.svg;;
preferences*)y=configuration.svg;;
*info*)y=help.svg;;
esac
cp -af "${SRC_DIR}/categories/$c" ${TGT_DIR}/${y}
done
echo "done!"
)
fi