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