forked from SchildiChat/matrix-react-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme.sh
executable file
·152 lines (139 loc) · 5.92 KB
/
theme.sh
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
#!/bin/bash
shopt -s globstar
mydir="$(dirname "$(realpath "$0")")"
automatic_commit="$1"
pushd "$mydir" > /dev/null
if [[ "$automatic_commit" == [Yy]* ]]; then
# Require clean git state
uncommitted=`git status --porcelain`
if [ ! -z "$uncommitted" ]; then
echo "Uncommitted changes are present, please commit first!"
exit 1
fi
fi
M_ACCENT="#8BC34A"
M_ACCENT_DEC="139, 195, 74"
M_ACCENT_DARK="#33691E"
M_ACCENT_LIGHT="#DCEDC8"
M_ALERT="#E53935"
M_LINK="#368bd6"
replace_colors() {
local f="$1"
if [[ "$f" =~ "dark" ]]; then
BG_ACCENT="$M_ACCENT_DARK"
CODEBLOCK_BACKGROUND_COLOR="#121212"
PILL_COLOR="rgba(255, 255, 255, 0.15)"
PILL_HOVER_COLOR="rgba(255, 255, 255, 0.18)"
PRESENCE_OFFLINE="#e0e0e0" # not applied because not existing specifically for dark
else
BG_ACCENT="$M_ACCENT_LIGHT"
CODEBLOCK_BACKGROUND_COLOR="#00000010"
PILL_COLOR="rgba(0, 0, 0, 0.13)"
PILL_HOVER_COLOR="rgba(0, 0, 0, 0.10)"
PRESENCE_OFFLINE="#bdbdbd" # for light this should actually be darker
fi
# Neutral colors
sed -i 's|#15171b|#212121|gi' "$f"
sed -i 's|#15191E|#212121|gi' "$f"
sed -i 's|#2e2f32|#212121|gi' "$f"
sed -i 's|#232f32|#212121|gi' "$f"
sed -i 's|#27303a|#212121|gi' "$f"
sed -i 's|#17191C|#212121|gi' "$f"
sed -i 's|#181b21|#303030|gi' "$f"
sed -i 's|#1A1D23|#303030|gi' "$f"
sed -i 's|#20252B|#303030|gi' "$f"
sed -i 's|#20252c|#303030|gi' "$f"
sed -i 's|#21262c|#383838|gi' "$f" # selection/hover color
sed -i 's|#238cf5|#303030|gi' "$f"
sed -i 's|#25271F|#303030|gi' "$f"
sed -i 's|#272c35|#303030|gi' "$f"
sed -i 's|#2a3039|#303030|gi' "$f"
sed -i 's|#343a46|#424242|gi' "$f"
sed -i 's|#3c4556|#424242|gi' "$f"
sed -i 's|#3d3b39|#424242|gi' "$f"
sed -i 's|#45474a|#424242|gi' "$f"
sed -i 's|#454545|#424242|gi' "$f"
sed -i 's|#2e3649|#424242|gi' "$f"
sed -i 's|#4e5054|#424242|gi' "$f"
sed -i 's|#394049|#424242|gi' "$f"
sed -i 's|#3e444c|#424242|gi' "$f"
sed -i 's|#61708b|#616161|gi' "$f"
sed -i 's|#616b7f|#616161|gi' "$f"
sed -i 's|#5c6470|#616161|gi' "$f"
sed -i 's|#545a66|#616161|gi' "$f" # pill hover bg color
sed -i 's|#737D8C|#757575|gi' "$f"
sed -i 's|#6F7882|#757575|gi' "$f"
sed -i 's|#91A1C0|#757575|gi' "$f" # icon in button color
sed -i 's|#8D99A5|#808080|gi' "$f"
sed -i 's|#8E99A4|#808080|gi' "$f" # maybe use #9e9e9e instead
sed -i 's|#8D97A5|#808080|gi' "$f"
sed -i 's|#a2a2a2|#9e9e9e|gi' "$f"
sed -i 's|#9fa9ba|#aaaaaa|gi' "$f" # maybe use #9e9e9e instead
sed -i 's|#acacac|#aaaaaa|gi' "$f" # maybe use #9e9e9e instead
sed -i 's|#B9BEC6|#b3b3b3|gi' "$f" # maybe use #bdbdbd instead
sed -i 's|#a1b2d1|#b3b3b3|gi' "$f"
sed -i 's|#A9B2BC|#b3b3b3|gi' "$f"
sed -i 's|#C1C6CD|#bdbdbd|gi' "$f"
sed -i 's|#c1c9d6|#bdbdbd|gi' "$f"
sed -i 's|#c8c8cd|#cccccc|gi' "$f" # maybe use #bdbdbd instead
# sed -i 's|#dddddd|#e0e0e0|gi' "$f" # really?
sed -i 's|#e7e7e7|#e0e0e0|gi' "$f"
sed -i 's|#e3e8f0|#e0e0e0|gi' "$f"
sed -i 's|#e9e9e9|#e0e0e0|gi' "$f"
sed -i 's|#e9edf1|#e0e0e0|gi' "$f"
sed -i 's|#e8eef5|#e0e0e0|gi' "$f"
sed -i 's|#deddfd|#e0e0e0|gi' "$f" # $location-live-secondary-color, what to use really?
sed -i 's|#edf3ff|#eeeeee|gi' "$f"
sed -i 's|#f4f6fa|#f5f5f5|gi' "$f"
sed -i 's|#f6f7f8|#f5f5f5|gi' "$f"
sed -i 's|#f2f5f8|#f5f5f5|gi' "$f"
sed -i 's|#f5f8fa|#f5f5f5|gi' "$f"
sed -i 's|#f3f8fd|#fafafa|gi' "$f"
sed -i 's|rgba(33, 38, 34,|rgba(48, 48, 48,|gi' "$f"
sed -i 's|rgba(33, 38, 44,|rgba(48, 48, 48,|gi' "$f"
sed -i 's|rgba(34, 38, 46,|rgba(48, 48, 48,|gi' "$f"
sed -i 's|rgba(38, 39, 43,|rgba(48, 48, 48,|gi' "$f"
sed -i 's|rgba(46, 48, 51,|rgba(48, 48, 48,|gi' "$f"
sed -i 's|rgba(92, 100, 112,|rgba(97, 97, 97,|gi' "$f"
sed -i 's|rgba(141, 151, 165,|rgba(144, 144, 144,|gi' "$f"
sed -i 's|rgba(242, 245, 248,|rgba(248, 248, 248,|gi' "$f"
sed -i "s|\\(\$event-highlight-bg-color: \\).*;|\\1transparent;|gi" "$f"
sed -i "s|\\(\$preview-widget-bar-color: \\).*;|\\1#bdbdbd;|gi" "$f"
sed -i "s|\\(\$blockquote-bar-color: \\).*;|\\1#bdbdbd;|gi" "$f"
sed -i "s|\\(\$pill-bg-color: \\).*;|\\1$PILL_COLOR;|gi" "$f"
sed -i "s|\\(\$pill-hover-bg-color: \\).*;|\\1$PILL_HOVER_COLOR;|gi" "$f"
sed -i "s|\\(\$codeblock-background-color: \\).*;|\\1$CODEBLOCK_BACKGROUND_COLOR;|gi" "$f"
sed -i "s|\\(\$presence-offline: \\).*;|\\1$PRESENCE_OFFLINE;|gi" "$f"
# Accent colors
sed -i "s|#368bd6|$M_ACCENT|gi" "$f"
sed -i "s|#ac3ba8|$M_ACCENT|gi" "$f"
sed -i "s|#0DBD8B|$M_ACCENT|gi" "$f"
sed -i "s|#e64f7a|$M_ACCENT|gi" "$f"
sed -i "s|#ff812d|$M_ACCENT|gi" "$f"
sed -i "s|#2dc2c5|$M_ACCENT|gi" "$f"
sed -i "s|#5c56f5|$M_ACCENT|gi" "$f"
sed -i "s|#74d12c|$M_ACCENT|gi" "$f"
sed -i "s|#76CFA6|$M_ACCENT|gi" "$f"
sed -i "s|#03b381|$M_ACCENT|gi" "$f"
sed -i "s|rgba(3, 179, 129,|rgba($M_ACCENT_DEC,|gi" "$f"
sed -i "s|#03b381|$M_ACCENT|gi" "$f"
sed -i "s|#FF5B55|$M_ALERT|gi" "$f"
sed -i "s|\\(\$accent-alt: \\).*;|\\1$M_LINK;|gi" "$f"
#sed -i "s|\\(\$accent-darker: \\).*;|\\1$M_ACCENT_DARK;|gi" "$f"
sed -i "s|\\(\$roomtile-default-badge-bg-color: \\).*;|\\1$M_ACCENT;|gi" "$f"
#sed -i "s|\\(\$input-focused-border-color: \\).*;|\\1\$accent;|gi" "$f" # not existing anymore, need replacement?
sed -i "s|\\(\$reaction-row-button-selected-bg-color: \\).*;|\\1$BG_ACCENT;|gi" "$f"
}
replace_colors res/themes/dark/css/_dark.scss
replace_colors res/themes/light/css/_light.scss
replace_colors res/themes/legacy-light/css/_legacy-light.scss
replace_colors res/themes/legacy-dark/css/_legacy-dark.scss
for f in res/**/*.svg; do
replace_colors "$f"
done
popd > /dev/null
if [[ "$automatic_commit" == [Yy]* ]]; then
# see: https://devops.stackexchange.com/a/5443
git add -A
git diff-index --quiet HEAD || git commit -m "Automatic theme update"
fi