-
Notifications
You must be signed in to change notification settings - Fork 7
/
change-theme
executable file
·78 lines (69 loc) · 3.08 KB
/
change-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
#!/bin/bash
# This script is a part of Clarity Vector Icon theme for GTK
# Copyright (C) 2010 Jakub Jankiewicz <http://jcubic.pl>
BASE=.
theme=$(ls ${BASE}/src/template_*.svg | sed -e 's/.*template_\(.*\)\.svg/\1/' | zenity --list --title="Select The Theme" --column=theme 2> /dev/null)
#user don't select the theme
[ -z "$theme" ] && exit
function symlinks() {
grep -v '^#' src/symlinks | tr -d '\r' | grep -v '^ *$'
}
function copies() {
grep -v '^#' src/copies | tr -d '\r' | grep -v '^ *$'
}
SKIP=`grep -v '^#' src/16x16_exceptions | tr -d '\r' | grep -v '^ *$' | paste -sd '|' - | sed -e 's/.*/(&)/'`
#variables for counting progress
num=$(find ${BASE}/src -mindepth 2 -type f -name "*.svg" | wc -l)
count=0
rcount=$(grep -v '^#' ${BASE}/src/compound_icons_rules | grep -v '^ *$' | wc -l)
lcount=$(echo $SYMLINKS | grep -vE "$SKIP" | wc -l)
#num=`echo $num+$rcount | bc`
function progress() {
(( count++ ));
(( percent = (count*99)/$1 ));
echo $percent;
}
test -d scalable || mkdir scalable
test -d 16x16 || mkdir 16x16
for dir in `cd src && ls -d */`; do
test -d scalable/$dir || mkdir scalable/$dir
test -d 16x16/$dir || mkdir 16x16/$dir
done
{
#find all icons in src directory
for i in $(find ${BASE}/src -mindepth 2 -name "*.svg" -type f); do
SHAPE=$(grep "path.*d=" $i | sed -e "s/.*d=\"\([^\"]*\)\".*/\1/";);
TITLE=$(grep "<title>" $i | sed -e "s/.*<title>\([^<]*\)<\/title>/\1/");
#replace d attribute of source icons in template and save it in scalable directory
sed -e "s/{{PATH}}/${SHAPE}/" -e "s/{{TITLE}}/${TITLE}/" ${BASE}/src/template_${theme}.svg > `echo $i | sed -e "s/src/scalable/"`;
progress $num
done
find static -type f | sed -e 's/[^\/]*\/\(.*\)/cp & scalable\/\1/' | bash
IFS=$'\n'
count=0
#skip comments and empty lines
for i in $(grep -v '^#' ${BASE}/src/compound_icons_rules | grep -v '^ *$'); do
if $(echo $i | grep -e ".*=.*\+.*" > /dev/null); then
#if rule is valid process rules
desc=$(echo $i | sed -e 's/\([^= ]*\) *=.*/\1/')
source=$(echo $i | sed -e 's/[^=]*= *\([^ ]*\) *\+.*/\1/')
element=$(echo $i | sed -e 's/.*+ *\(.*\) *$/\1/')
sed -e "s%</svg>%`grep 'id=\"shape\"' ${BASE}/src/$element`\n\<\/svg\>%" ${BASE}/scalable/$source > ${BASE}/scalable/$desc;
else
zenity --error --title="src/compound_icons_rules corupted" --text="bad line in $RULES_FILE file\n '$i'"
fi
progress $rcount
done
symlinks | sed 's/^/ln -sf /g' | bash
copies | sed 's/^/cp /g' | bash
count=0
symlinks | sed -e 's/\.svg/\.png/g' -e 's/scalable/16x16/g' -e 's/^/ln -sf /g' | grep -vE $SKIP | sh
for i in $(find scalable -type f | grep -vE $SKIP); do
desc=$(echo $i | sed -e 's/scalable\(.*\)svg/16x16\1png/')
rsvg-convert -w 16 -h 16 $i > $desc
progress $lcount
done
copies | sed -e 's/\.svg/\.png/g' -e 's/scalable/16x16/g' -e 's/^/cp /g' | grep -vE $SKIP | bash
echo 100
echo "# Completed"
} | zenity --progress --title="Building ${theme} icons" --width=250