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 • 10.34 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
GTK_VERSIONS=('3.0')
14
GS_VERSIONS=('3.26' '3.28' '3.30' '3.32' '3.34' '3.36')
15
LATEST_GS_VERSION="${GS_VERSIONS[-1]}"
16
17
if test -z "${GS_VERSION:-}"; then
18
# Set a proper gnome-shell theme version
19
if command -v gnome-shell >/dev/null; then
20
CURRENT_GS_VERSION="$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -2)"
21
for version in "${GS_VERSIONS[@]}"; do
22
if (( "$(bc <<< "$CURRENT_GS_VERSION <= $version")" )); then
23
GS_VERSION="$version"
24
break
25
else
26
GS_VERSION="$LATEST_GS_VERSION"
27
fi
28
done
29
else
30
GS_VERSION="$LATEST_GS_VERSION"
31
fi
32
fi
33
34
if [[ ! "$(command -v sassc)" ]]; then
35
echo "'sassc' needs to be installed to generate the CSS."
36
exit 1
37
fi
38
39
SASSC_OPT=('-M' '-t' 'expanded')
40
41
usage() {
42
cat << EOF
43
Usage: $0 [OPTION]...
44
45
OPTIONS:
46
-d, --dest DIR Specify destination directory (Default: $DEST_DIR)
47
-n, --name NAME Specify theme name (Default: $THEME_NAME)
48
-c, --color VARIANT... Specify color variant(s) [standard|dark|light] (Default: All variants)
49
-s, --size VARIANT Specify size variant [standard|compact] (Default: All variants)
50
-g, --gdm Install and apply GDM theme (for advanced users)
51
See also: src/gnome-shell/README.md
52
-h, --help Show help
53
54
INSTALLATION EXAMPLES:
55
Install all theme variants into ~/.themes
56
$0 --dest ~/.themes
57
Install all theme variants including GDM theme
58
$0 --gdm
59
Install standard theme variant only
60
$0 --color standard --size standard
61
Install specific theme variants with different name into ~/.themes
62
$0 --dest ~/.themes --name MyTheme --color light dark --size compact
63
EOF
64
}
65
66
install() {
67
local dest="$1"
68
local name="$2$3$4"
69
local color="$3"
70
local size="$4"
71
72
if [[ "$color" == '' ]]; then
73
local scss_variant="light"
74
local scss_topbar="dark"
75
elif [[ "$color" == '-light' ]]; then
76
local scss_variant="light"
77
local scss_topbar="light"
78
elif [[ "$color" == '-dark' ]]; then
79
local scss_variant="dark"
80
local scss_topbar="dark"
81
fi
82
83
if [[ "$size" == '' ]]; then
84
local scss_compact="false"
85
elif [[ "$size" == '-compact' ]]; then
86
local scss_compact="true"
87
fi
88
89
[[ "$color" == '-dark' ]] && local ELSE_DARK="$color"
90
[[ "$color" == '-light' ]] && local ELSE_LIGHT="$color"
91
92
local THEME_DIR="$dest/$name"
93
94
# SC2115: Protect /.
95
[[ -d "$THEME_DIR" ]] && rm -rf "${THEME_DIR:?}"
96
97
echo "Installing '$THEME_DIR'..."
98
99
mkdir -p "$THEME_DIR"
100
cp -r "$REPO_DIR/COPYING" "$THEME_DIR"
101
sed \
102
-e "s/@theme_name@/$name/g" \
103
"$SRC_DIR/index.theme.in" > "$THEME_DIR/index.theme"
104
105
mkdir -p "$THEME_DIR/chrome"
106
cp -r "$SRC_DIR/chrome/chrome-theme$color.crx" "$THEME_DIR/chrome/chrome-theme.crx"
107
cp -r "$SRC_DIR/chrome/chrome-scrollbar${ELSE_DARK:-}.crx" "$THEME_DIR/chrome/chrome-scrollbar.crx"
108
109
mkdir -p "$THEME_DIR/cinnamon"
110
cp -r "$SRC_DIR/cinnamon/assets" "$THEME_DIR/cinnamon"
111
cp -r "$SRC_DIR/cinnamon/thumbnail.png" "$THEME_DIR/cinnamon"
112
sed \
113
-e "s/@variant@/$scss_variant/g" \
114
-e "s/@topbar@/$scss_topbar/g" \
115
-e "s/@compact@/$scss_compact/g" \
116
"$SRC_DIR/cinnamon/cinnamon.scss.in" > "$SRC_DIR/cinnamon/cinnamon.$name.scss"
117
sassc "${SASSC_OPT[@]}" "$SRC_DIR/cinnamon/cinnamon.$name.scss" "$THEME_DIR/cinnamon/cinnamon.css"
118
119
mkdir -p "$THEME_DIR/gnome-shell"
120
cp -r "$SRC_DIR/gnome-shell/"{*.svg,extensions,noise-texture.png,pad-osd.css} "$THEME_DIR/gnome-shell"
121
cp -r "$SRC_DIR/gnome-shell/gnome-shell-theme.gresource.xml" "$THEME_DIR/gnome-shell"
122
cp -r "$SRC_DIR/gnome-shell/icons" "$THEME_DIR/gnome-shell"
123
cp -r "$SRC_DIR/gnome-shell/README.md" "$THEME_DIR/gnome-shell"
124
cp -r "$SRC_DIR/gnome-shell/assets${ELSE_DARK:-}" "$THEME_DIR/gnome-shell/assets"
125
sed \
126
-e "s/@variant@/$scss_variant/g" \
127
-e "s/@topbar@/$scss_topbar/g" \
128
-e "s/@compact@/$scss_compact/g" \
129
-e "s/@version@/$GS_VERSION/g" \
130
"$SRC_DIR/gnome-shell/gnome-shell.scss.in" > "$SRC_DIR/gnome-shell/gnome-shell.$name.scss"
131
sassc "${SASSC_OPT[@]}" "$SRC_DIR/gnome-shell/gnome-shell.$name.scss" "$THEME_DIR/gnome-shell/gnome-shell.css"
132
133
mkdir -p "$THEME_DIR/gtk-2.0"
134
cp -r "$SRC_DIR/gtk-2.0/"{apps.rc,hacks.rc,main.rc} "$THEME_DIR/gtk-2.0"
135
cp -r "$SRC_DIR/gtk-2.0/assets${ELSE_DARK:-}" "$THEME_DIR/gtk-2.0/assets"
136
cp -r "$SRC_DIR/gtk-2.0/gtkrc$color" "$THEME_DIR/gtk-2.0/gtkrc"
137
138
cp -r "$SRC_DIR/gtk/assets" "$THEME_DIR/gtk-assets"
139
cp -r "$SRC_DIR/gtk/icons" "$THEME_DIR/gtk-icons"
140
141
local GTK_VARIANTS=('')
142
[[ "$color" != '-dark' ]] && local GTK_VARIANTS+=('-dark')
143
144
for version in "${GTK_VERSIONS[@]}"; do
145
mkdir -p "$THEME_DIR/gtk-$version"
146
ln -s ../gtk-assets "$THEME_DIR/gtk-$version/assets"
147
ln -s ../gtk-icons "$THEME_DIR/gtk-$version/icons"
148
149
for variant in "${GTK_VARIANTS[@]}"; do
150
sed \
151
-e "s/@variant@/$scss_variant/g" \
152
-e "s/@topbar@/$scss_topbar/g" \
153
-e "s/@compact@/$scss_compact/g" \
154
"$SRC_DIR/gtk/gtk$variant.scss.in" > "$SRC_DIR/gtk/gtk$variant.gtk-$version.$name.scss"
155
sassc "${SASSC_OPT[@]}" "$SRC_DIR/gtk/gtk$variant.gtk-$version.$name.scss" "$THEME_DIR/gtk-$version/gtk$variant.css"
156
done
157
done
158
159
mkdir -p "$THEME_DIR/metacity-1"
160
cp -r "$SRC_DIR/metacity-1/"{assets,metacity-theme-3.xml} "$THEME_DIR/metacity-1"
161
cp -r "$SRC_DIR/metacity-1/metacity-theme-2$color.xml" "$THEME_DIR/metacity-1/metacity-theme-2.xml"
162
163
mkdir -p "$THEME_DIR/plank"
164
cp -r "$SRC_DIR/plank/dock.theme" "$THEME_DIR/plank"
165
166
mkdir -p "$THEME_DIR/unity"
167
cp -rT "$SRC_DIR/unity/dash-buttons" "$THEME_DIR/unity"
168
cp -r "$SRC_DIR/unity/dash-widgets.json" "$THEME_DIR/unity"
169
cp -rT "$SRC_DIR/unity/launcher" "$THEME_DIR/unity"
170
cp -rT "$SRC_DIR/unity/window-buttons${ELSE_LIGHT:-}" "$THEME_DIR/unity"
171
172
cp -r "$SRC_DIR/xfwm4/xfwm4$color" "$THEME_DIR/xfwm4"
173
}
174
175
# Bakup and install files related to GDM theme
176
install_gdm() {
177
local THEME_DIR="$1/$2$3$4"
178
local GS_THEME_FILE="/usr/share/gnome-shell/gnome-shell-theme.gresource"
179
local UBUNTU_THEME_FILE="/usr/share/gnome-shell/theme/ubuntu.css"
180
181
if [[ -f "$GS_THEME_FILE" ]] && command -v glib-compile-resources >/dev/null; then
182
echo "Installing '$GS_THEME_FILE'..."
183
cp -an "$GS_THEME_FILE" "$GS_THEME_FILE.bak"
184
glib-compile-resources \
185
--sourcedir="$THEME_DIR/gnome-shell" \
186
--target="$GS_THEME_FILE" \
187
"$THEME_DIR/gnome-shell/gnome-shell-theme.gresource.xml"
188
else
189
echo
190
echo "ERROR: Failed to install '$GS_THEME_FILE'"
191
exit 1
192
fi
193
194
if [[ -f "$UBUNTU_THEME_FILE" ]]; then
195
echo "Installing '$UBUNTU_THEME_FILE'..."
196
cp -an "$UBUNTU_THEME_FILE" "$UBUNTU_THEME_FILE.bak"
197
cp -af "$THEME_DIR/gnome-shell/gnome-shell.css" "$UBUNTU_THEME_FILE"
198
fi
199
}
200
201
colors=()
202
sizes=()
203
while [[ "$#" -gt 0 ]]; do
204
case "${1:-}" in
205
-d|--dest)
206
dest="$2"
207
mkdir -p "$dest"
208
shift 2
209
;;
210
-n|--name)
211
_name="$2"
212
shift 2
213
;;
214
-g|--gdm)
215
gdm='true'
216
shift 1
217
;;
218
-c|--color)
219
shift
220
for variant in "$@"; do
221
case "$variant" in
222
standard)
223
colors+=("${COLOR_VARIANTS[0]}")
224
shift
225
;;
226
dark)
227
colors+=("${COLOR_VARIANTS[1]}")
228
shift
229
;;
230
light)
231
colors+=("${COLOR_VARIANTS[2]}")
232
shift
233
;;
234
-*)
235
break
236
;;
237
*)
238
echo "ERROR: Unrecognized color variant '$1'."
239
echo "Try '$0 --help' for more information."
240
exit 1
241
;;
242
esac
243
done
244
;;
245
-s|--size)
246
shift
247
for variant in "$@"; do
248
case "$variant" in
249
standard)
250
sizes+=("${SIZE_VARIANTS[0]}")
251
shift
252
;;
253
compact)
254
sizes+=("${SIZE_VARIANTS[1]}")
255
shift
256
;;
257
-*)
258
break
259
;;
260
*)
261
echo "ERROR: Unrecognized size variant '${1:-}'."
262
echo "Try '$0 --help' for more information."
263
exit 1
264
;;
265
esac
266
done
267
;;
268
-h|--help)
269
usage
270
exit 0
271
;;
272
*)
273
echo "ERROR: Unrecognized installation option '${1:-}'."
274
echo "Try '$0 --help' for more information."
275
exit 1
276
;;
277
esac
278
done
279
280
if [[ ! -w "${dest:-$DEST_DIR}" ]]; then
281
echo "Please run as root."
282
exit 1
283
fi
284
285
if [[ "${#colors[@]}" -eq 0 ]] ; then
286
colors=("${COLOR_VARIANTS[@]}")
287
fi
288
if [[ "${#sizes[@]}" -eq 0 ]] ; then
289
sizes=("${SIZE_VARIANTS[@]}")
290
fi
291
for color in "${colors[@]}"; do
292
for size in "${sizes[@]}"; do
293
install "${dest:-$DEST_DIR}" "${_name:-$THEME_NAME}" "$color" "$size"
294
done
295
done
296
297
if [[ "${gdm:-}" == 'true' ]]; then
298
install_gdm "${dest:-$DEST_DIR}" "${_name:-$THEME_NAME}" "$color" "$size"
299
fi
300
301
echo
302
echo "Done."
303