A fork of the Materia GTK theme.

Important information: Google announced that, from September 2026, Android devices will require ALL apps to be signed by Google, effectively leading to an iOS situation. Value your right to a computer that does what you want; do not tolerate this monopolistic practice! Contact me if you don't understand why it is bad. Click to learn more.

 install.sh

View raw Download
text/x-shellscript • 11.85 kiB
Bourne-Again shell script, ASCII text executable
        
            
1
#!/bin/bash
2
set -ueo pipefail
3
#set -x
4
5
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
6
SRC_DIR="$REPO_DIR/src"
7
8
DEST_DIR="/usr/share/themes"
9
THEME_NAME="Materia"
10
COLOR_VARIANTS=('' '-dark' '-light')
11
SIZE_VARIANTS=('' '-compact')
12
13
# Set a proper gtk4 theme version
14
if [[ -z "${GTK4_VERSION:-}" ]]; then
15
if [[ "$(command -v gtk4-launch)" ]]; then
16
GTK4_FULL_VERSION="$(gtk4-launch --version)"
17
GTK4_MAJOR_VERSION="$(echo "$GTK4_FULL_VERSION" | cut -d . -f 1)"
18
GTK4_MINOR_VERSION="$(echo "$GTK4_FULL_VERSION" | cut -d . -f 2)"
19
20
if (( "$GTK4_MINOR_VERSION" % 2 == 0 )); then
21
GTK4_VERSION="$GTK4_MAJOR_VERSION.$GTK4_MINOR_VERSION"
22
else
23
GTK4_VERSION="$GTK4_MAJOR_VERSION.$((GTK4_MINOR_VERSION + 1))"
24
fi
25
else
26
echo "'gtk4-launch' not found, using styles for last gtk4 version available."
27
GTK4_VERSION="4.0"
28
fi
29
fi
30
31
# Set a proper gnome-shell theme version
32
if [[ -z "${GS_VERSION:-}" ]]; then
33
if [[ "$(command -v gnome-shell)" ]]; then
34
GS_FULL_VERSION="$(gnome-shell --version | rev | cut -d ' ' -f 1 | rev)"
35
GS_MAJOR_VERSION="$(echo "$GS_FULL_VERSION" | cut -d . -f 1)"
36
GS_MINOR_VERSION="$(echo "$GS_FULL_VERSION" | cut -d . -f 2)"
37
38
if (( "$GS_MAJOR_VERSION" >= 40 )); then
39
GS_VERSION="$GS_MAJOR_VERSION"
40
elif (( "$GS_MINOR_VERSION" % 2 == 0 )); then
41
GS_VERSION="$GS_MAJOR_VERSION.$GS_MINOR_VERSION"
42
else
43
GS_VERSION="$GS_MAJOR_VERSION.$((GS_MINOR_VERSION + 1))"
44
fi
45
else
46
echo "'gnome-shell' not found, using styles for last gnome-shell version available."
47
GS_VERSION="3.36"
48
fi
49
fi
50
51
if [[ ! "$(command -v sassc)" ]]; then
52
echo "'sassc' needs to be installed to generate the CSS."
53
exit 1
54
fi
55
56
SASSC_OPT=('-M' '-t' 'expanded')
57
58
usage() {
59
cat << EOF
60
Usage: $0 [OPTION]...
61
62
OPTIONS:
63
-d, --dest DIR Specify destination directory (Default: $DEST_DIR)
64
-n, --name NAME Specify theme name (Default: $THEME_NAME)
65
-c, --color VARIANT... Specify color variant(s) [standard|dark|light] (Default: All variants)
66
-s, --size VARIANT Specify size variant [standard|compact] (Default: All variants)
67
-g, --gdm Install and apply GDM theme (for advanced users)
68
See also: src/gnome-shell/README.md
69
-h, --help Show help
70
71
INSTALLATION EXAMPLES:
72
Install all theme variants into ~/.themes
73
$0 --dest ~/.themes
74
Install all theme variants including GDM theme
75
$0 --gdm
76
Install standard theme variant only
77
$0 --color standard --size standard
78
Install specific theme variants with different name into ~/.themes
79
$0 --dest ~/.themes --name MyTheme --color light dark --size compact
80
EOF
81
}
82
83
install() {
84
local dest="$1"
85
local name="$2$3$4"
86
local color="$3"
87
local size="$4"
88
89
if [[ "$color" == '' ]]; then
90
local scss_dark_theme="false"
91
local scss_light_topbar="false"
92
elif [[ "$color" == '-light' ]]; then
93
local scss_dark_theme="false"
94
local scss_light_topbar="true"
95
elif [[ "$color" == '-dark' ]]; then
96
local scss_dark_theme="true"
97
local scss_light_topbar="false"
98
fi
99
100
if [[ "$size" == '' ]]; then
101
local scss_compact="false"
102
elif [[ "$size" == '-compact' ]]; then
103
local scss_compact="true"
104
fi
105
106
[[ "$color" == '-dark' ]] && local ELSE_DARK="$color"
107
[[ "$color" == '-light' ]] && local ELSE_LIGHT="$color"
108
109
local THEME_DIR="$dest/$name"
110
111
# SC2115: Protect /.
112
[[ -d "$THEME_DIR" ]] && rm -rf "${THEME_DIR:?}"
113
114
echo "Installing '$THEME_DIR'..."
115
116
#
117
# COPYING & index.theme
118
#
119
120
mkdir -p "$THEME_DIR"
121
cp -r "$REPO_DIR/COPYING" "$THEME_DIR"
122
sed \
123
-e "s/@theme_name@/$name/g" \
124
"$SRC_DIR/index.theme.in" > "$THEME_DIR/index.theme"
125
126
#
127
# Chrome extensions
128
#
129
130
mkdir -p "$THEME_DIR/chrome"
131
cp -r "$SRC_DIR/chrome/chrome-theme$color.crx" "$THEME_DIR/chrome/chrome-theme.crx"
132
cp -r "$SRC_DIR/chrome/chrome-scrollbar${ELSE_DARK:-}.crx" "$THEME_DIR/chrome/chrome-scrollbar.crx"
133
134
#
135
# Cinnamon
136
#
137
138
mkdir -p "$THEME_DIR/cinnamon"
139
cp -r "$SRC_DIR/cinnamon/assets" "$THEME_DIR/cinnamon"
140
cp -r "$SRC_DIR/cinnamon/thumbnail.png" "$THEME_DIR/cinnamon"
141
sed \
142
-e "s/@dark_theme@/$scss_dark_theme/g" \
143
-e "s/@light_topbar@/$scss_light_topbar/g" \
144
-e "s/@compact@/$scss_compact/g" \
145
-e "s#@current_source_dir@#$SRC_DIR/cinnamon#g" \
146
"$SRC_DIR/cinnamon/cinnamon.scss.in" | \
147
sassc --stdin "${SASSC_OPT[@]}" "$THEME_DIR/cinnamon/cinnamon.css"
148
149
#
150
# GNOME Shell
151
#
152
153
mkdir -p "$THEME_DIR/gnome-shell"
154
cp -r "$SRC_DIR/gnome-shell/extensions" "$THEME_DIR/gnome-shell"
155
cp -r "$SRC_DIR/gnome-shell/gnome-shell-theme.gresource.xml" "$THEME_DIR/gnome-shell"
156
cp -r "$SRC_DIR/gnome-shell/icons" "$THEME_DIR/gnome-shell"
157
cp -r "$SRC_DIR/gnome-shell/noise-texture.png" "$THEME_DIR/gnome-shell"
158
cp -r "$SRC_DIR/gnome-shell/pad-osd.css" "$THEME_DIR/gnome-shell"
159
cp -r "$SRC_DIR/gnome-shell/process-working.svg" "$THEME_DIR/gnome-shell"
160
cp -r "$SRC_DIR/gnome-shell/README.md" "$THEME_DIR/gnome-shell"
161
cp -r "$SRC_DIR/gnome-shell/assets${ELSE_DARK:-}" "$THEME_DIR/gnome-shell/assets"
162
sed \
163
-e "s/@dark_theme@/$scss_dark_theme/g" \
164
-e "s/@light_topbar@/$scss_light_topbar/g" \
165
-e "s/@compact@/$scss_compact/g" \
166
-e "s/@version@/$GS_VERSION/g" \
167
-e "s#@current_source_dir@#$SRC_DIR/gnome-shell#g" \
168
"$SRC_DIR/gnome-shell/gnome-shell.scss.in" | \
169
sassc --stdin "${SASSC_OPT[@]}" "$THEME_DIR/gnome-shell/gnome-shell.css"
170
171
#
172
# GTK 2
173
#
174
175
mkdir -p "$THEME_DIR/gtk-2.0"
176
cp -r "$SRC_DIR/gtk-2.0/apps.rc" "$THEME_DIR/gtk-2.0"
177
cp -r "$SRC_DIR/gtk-2.0/hacks.rc" "$THEME_DIR/gtk-2.0"
178
cp -r "$SRC_DIR/gtk-2.0/main.rc" "$THEME_DIR/gtk-2.0"
179
cp -r "$SRC_DIR/gtk-2.0/assets${ELSE_DARK:-}" "$THEME_DIR/gtk-2.0/assets"
180
cp -r "$SRC_DIR/gtk-2.0/gtkrc$color" "$THEME_DIR/gtk-2.0/gtkrc"
181
182
#
183
# GTK 3 & 4
184
#
185
186
local GTK_VARIANTS=('')
187
[[ "$color" != '-dark' ]] && local GTK_VARIANTS+=('-dark')
188
189
for version in "3.0" "4.0"; do
190
mkdir -p "$THEME_DIR/gtk-$version"
191
cp -r "$SRC_DIR/gtk-3.0/assets" "$THEME_DIR/gtk-$version"
192
cp -r "$SRC_DIR/gtk-3.0/icons" "$THEME_DIR/gtk-$version"
193
194
for variant in "${GTK_VARIANTS[@]}"; do
195
sed \
196
-e "s/@dark_theme@/$scss_dark_theme/g" \
197
-e "s/@light_topbar@/$scss_light_topbar/g" \
198
-e "s/@compact@/$scss_compact/g" \
199
-e "s/@version@/$GTK4_VERSION/g" \
200
-e "s#@current_source_dir@#$SRC_DIR/gtk-$version#g" \
201
"$SRC_DIR/gtk-$version/gtk$variant.scss.in" | \
202
sassc --stdin "${SASSC_OPT[@]}" "$THEME_DIR/gtk-$version/gtk$variant.css"
203
done
204
done
205
206
#
207
# Metacity
208
#
209
210
mkdir -p "$THEME_DIR/metacity-1"
211
cp -r "$SRC_DIR/metacity-1/assets" "$THEME_DIR/metacity-1"
212
cp -r "$SRC_DIR/metacity-1/metacity-theme-3.xml" "$THEME_DIR/metacity-1"
213
cp -r "$SRC_DIR/metacity-1/metacity-theme-2$color.xml" "$THEME_DIR/metacity-1/metacity-theme-2.xml"
214
215
#
216
# Plank
217
#
218
219
mkdir -p "$THEME_DIR/plank"
220
cp -r "$SRC_DIR/plank/dock.theme" "$THEME_DIR/plank"
221
222
#
223
# Unity
224
#
225
226
mkdir -p "$THEME_DIR/unity"
227
cp -rT "$SRC_DIR/unity/dash-buttons" "$THEME_DIR/unity"
228
cp -r "$SRC_DIR/unity/dash-widgets.json" "$THEME_DIR/unity"
229
cp -rT "$SRC_DIR/unity/launcher" "$THEME_DIR/unity"
230
cp -rT "$SRC_DIR/unity/window-buttons${ELSE_LIGHT:-}" "$THEME_DIR/unity"
231
232
#
233
# Xfwm4
234
#
235
236
cp -r "$SRC_DIR/xfwm4/xfwm4$color" "$THEME_DIR/xfwm4"
237
}
238
239
# Bakup and install files related to GDM theme
240
install_gdm() {
241
local THEME_DIR="$1/$2$3$4"
242
local GS_THEME_FILE="/usr/share/gnome-shell/gnome-shell-theme.gresource"
243
local UBUNTU_THEME_FILE="/usr/share/gnome-shell/theme/ubuntu.css"
244
245
if [[ -f "$GS_THEME_FILE" ]] && command -v glib-compile-resources >/dev/null; then
246
echo "Installing '$GS_THEME_FILE'..."
247
cp -an "$GS_THEME_FILE" "$GS_THEME_FILE.bak"
248
glib-compile-resources \
249
--sourcedir="$THEME_DIR/gnome-shell" \
250
--target="$GS_THEME_FILE" \
251
"$THEME_DIR/gnome-shell/gnome-shell-theme.gresource.xml"
252
else
253
echo
254
echo "ERROR: Failed to install '$GS_THEME_FILE'"
255
exit 1
256
fi
257
258
if [[ -f "$UBUNTU_THEME_FILE" ]]; then
259
echo "Installing '$UBUNTU_THEME_FILE'..."
260
cp -an "$UBUNTU_THEME_FILE" "$UBUNTU_THEME_FILE.bak"
261
cp -af "$THEME_DIR/gnome-shell/gnome-shell.css" "$UBUNTU_THEME_FILE"
262
fi
263
}
264
265
colors=()
266
sizes=()
267
while [[ "$#" -gt 0 ]]; do
268
case "${1:-}" in
269
-d|--dest)
270
dest="$2"
271
mkdir -p "$dest"
272
shift 2
273
;;
274
-n|--name)
275
_name="$2"
276
shift 2
277
;;
278
-g|--gdm)
279
gdm='true'
280
shift 1
281
;;
282
-c|--color)
283
shift
284
for variant in "$@"; do
285
case "$variant" in
286
standard)
287
colors+=("${COLOR_VARIANTS[0]}")
288
shift
289
;;
290
dark)
291
colors+=("${COLOR_VARIANTS[1]}")
292
shift
293
;;
294
light)
295
colors+=("${COLOR_VARIANTS[2]}")
296
shift
297
;;
298
-*)
299
break
300
;;
301
*)
302
echo "ERROR: Unrecognized color variant '$1'."
303
echo "Try '$0 --help' for more information."
304
exit 1
305
;;
306
esac
307
done
308
;;
309
-s|--size)
310
shift
311
for variant in "$@"; do
312
case "$variant" in
313
standard)
314
sizes+=("${SIZE_VARIANTS[0]}")
315
shift
316
;;
317
compact)
318
sizes+=("${SIZE_VARIANTS[1]}")
319
shift
320
;;
321
-*)
322
break
323
;;
324
*)
325
echo "ERROR: Unrecognized size variant '${1:-}'."
326
echo "Try '$0 --help' for more information."
327
exit 1
328
;;
329
esac
330
done
331
;;
332
-h|--help)
333
usage
334
exit 0
335
;;
336
*)
337
echo "ERROR: Unrecognized installation option '${1:-}'."
338
echo "Try '$0 --help' for more information."
339
exit 1
340
;;
341
esac
342
done
343
344
if [[ ! -w "${dest:-$DEST_DIR}" ]]; then
345
echo "Please run as root."
346
exit 1
347
fi
348
349
if [[ "${#colors[@]}" -eq 0 ]] ; then
350
colors=("${COLOR_VARIANTS[@]}")
351
fi
352
if [[ "${#sizes[@]}" -eq 0 ]] ; then
353
sizes=("${SIZE_VARIANTS[@]}")
354
fi
355
for color in "${colors[@]}"; do
356
for size in "${sizes[@]}"; do
357
install "${dest:-$DEST_DIR}" "${_name:-$THEME_NAME}" "$color" "$size"
358
done
359
done
360
361
if [[ "${gdm:-}" == 'true' ]]; then
362
install_gdm "${dest:-$DEST_DIR}" "${_name:-$THEME_NAME}" "$color" "$size"
363
fi
364
365
echo
366
echo "Done."
367