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