blob: 9e9bcbf84d2d9037f6a8232a2f1ec656d52cece4 (
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
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
|
#!/bin/bash
# This script automatically converts the rgb colors used for the layers in
# navit_layout_car_shipped.xml to the values appropriate for the dark layout in
# navit_layout_car_dark_shipped.xml.
# It's a bit of a mess, but gets the job done.
IFS='' # Keep whitespace
# Light and dark input files
ifl=navit_layout_car_shipped.xml
ifd=navit_layout_car_dark_shipped.xml
# Temporary dark output file
ofd=$ifd.new
# Iterate over all layers in dark input file
grep \<layer\ name=\" $ifd | cut -d\" -f2 | while read -r layer
do
echo $layer
# Create new temporary dark output file
[ -f $ofd ] && rm -f $ofd
touch $ofd
# Init: not in layer
inlayer=false
getlayer=false
# Read dark input file
while read -r l
do
# Check to see if inside layer - open tag
if [[ $l =~ .*\<layer\ name=\"$layer\"\>.* ]]; then
inlayer=true
getlayer=true
fi
# Check to see if inside layer - close tag
if [[ $l =~ .*\</layer\>.* ]]; then
inlayer=false
fi
# Trigger once when open tag found in dark input file
if [ $getlayer == true ]; then
getlayer=false # Just triggered
inlayer=false # Now used for light input file
# Insert data from light input file
while read -r l
do
# Check to see if inside layer
if [[ $l =~ .*\<layer\ name=\"$layer\"\>.* ]]; then
inlayer=true
fi
if [[ $l =~ .*\</layer\>.* ]]; then
inlayer=false
fi
# Inside layer
if [ $inlayer == true ]; then
# Modify color
if [[ $l =~ .*color=\"#[0-9a-fA-F]{6}.* ]]; then # Contains rgb(a) color
coll=$(echo $l | cut -d# -f2 | cut -c-6) # Get rgb color and convert
cold=$( printf '%02x' $(echo $(printf "%d" 0x${coll:0:2})/16+16 | bc))
cold=$cold$(printf '%02x' $(echo $(printf "%d" 0x${coll:2:2})/10+14 | bc))
cold=$cold$(printf '%02x' $(echo $(printf "%d" 0x${coll:4:2})/8+12 | bc))
l=$(echo $l | sed "s/#$coll/#$cold/") # Replace color
fi
# Misc. modifications
l=$(echo $l | sed -r "s/_bk\./_wh\./") # Black to white icons
l=$(echo $l | sed -r "s/(<text )/\1color=\"#55c4bd\" background_color=\"#000000\" /") # Add text color
l=$(echo $l | sed -r "s/(<circle color=\"#[0-9a-fA-F]{6,8}\" )/\1background_color=\"#000000\" /") # Add circle bg color
echo $l >> $ofd # Modified line from light input file to dark output file
fi
done < $ifl # Read light input file
inlayer=true # Done inserting, still in layer in dark input file
else
# Outside layer
if [ $inlayer == false ]; then
echo $l >> $ofd # Just copy as-is to dark output file
fi
fi
done < $ifd # Read dark input file
cp $ofd $ifd # Replace
rm -f $ofd # Clean up
done # Next layer in dark input file
|