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.11 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 -rT "$SRC_DIR/unity/dash-buttons" "$THEME_DIR/unity"
122
cp -r "$SRC_DIR/unity/dash-widgets.json" "$THEME_DIR/unity"
123
cp -rT "$SRC_DIR/unity/launcher" "$THEME_DIR/unity"
124
cp -rT "$SRC_DIR/unity/window-buttons${ELSE_LIGHT:-}" "$THEME_DIR/unity"
125
126
cp -r "$SRC_DIR/xfwm4/xfwm4$color" "$THEME_DIR/xfwm4"
127
}
128
129
# Bakup and install files related to GDM theme
130
install_gdm() {
131
local THEME_DIR="$1/$2$3$4"
132
local GS_THEME_FILE="/usr/share/gnome-shell/gnome-shell-theme.gresource"
133
local UBUNTU_THEME_FILE="/usr/share/gnome-shell/theme/ubuntu.css"
134
135
if [[ -f "$GS_THEME_FILE" ]] && command -v glib-compile-resources >/dev/null; then
136
echo "Installing '$GS_THEME_FILE'..."
137
cp -an "$GS_THEME_FILE" "$GS_THEME_FILE.bak"
138
glib-compile-resources \
139
--sourcedir="$THEME_DIR/gnome-shell" \
140
--target="$GS_THEME_FILE" \
141
"$THEME_DIR/gnome-shell/gnome-shell-theme.gresource.xml"
142
else
143
echo
144
echo "ERROR: Failed to install '$GS_THEME_FILE'"
145
exit 1
146
fi
147
148
if [[ -f "$UBUNTU_THEME_FILE" ]]; then
149
echo "Installing '$UBUNTU_THEME_FILE'..."
150
cp -an "$UBUNTU_THEME_FILE" "$UBUNTU_THEME_FILE.bak"
151
cp -af "$THEME_DIR/gnome-shell/gnome-shell.css" "$UBUNTU_THEME_FILE"
152
fi
153
}
154
155
colors=()
156
sizes=()
157
while [[ "$#" -gt 0 ]]; do
158
case "${1:-}" in
159
-d|--dest)
160
dest="$2"
161
mkdir -p "$dest"
162
shift 2
163
;;
164
-n|--name)
165
_name="$2"
166
shift 2
167
;;
168
-g|--gdm)
169
gdm='true'
170
shift 1
171
;;
172
-c|--color)
173
shift
174
for variant in "$@"; do
175
case "$variant" in
176
standard)
177
colors+=("${COLOR_VARIANTS[0]}")
178
shift
179
;;
180
dark)
181
colors+=("${COLOR_VARIANTS[1]}")
182
shift
183
;;
184
light)
185
colors+=("${COLOR_VARIANTS[2]}")
186
shift
187
;;
188
-*)
189
break
190
;;
191
*)
192
echo "ERROR: Unrecognized color variant '$1'."
193
echo "Try '$0 --help' for more information."
194
exit 1
195
;;
196
esac
197
done
198
;;
199
-s|--size)
200
shift
201
for variant in "$@"; do
202
case "$variant" in
203
standard)
204
sizes+=("${SIZE_VARIANTS[0]}")
205
shift
206
;;
207
compact)
208
sizes+=("${SIZE_VARIANTS[1]}")
209
shift
210
;;
211
-*)
212
break
213
;;
214
*)
215
echo "ERROR: Unrecognized size variant '${1:-}'."
216
echo "Try '$0 --help' for more information."
217
exit 1
218
;;
219
esac
220
done
221
;;
222
-h|--help)
223
usage
224
exit 0
225
;;
226
*)
227
echo "ERROR: Unrecognized installation option '${1:-}'."
228
echo "Try '$0 --help' for more information."
229
exit 1
230
;;
231
esac
232
done
233
234
if [[ ! -w "${dest:-$DEST_DIR}" ]]; then
235
echo "Please run as root."
236
exit 1
237
fi
238
239
if [[ "${#colors[@]}" -eq 0 ]] ; then
240
colors=("${COLOR_VARIANTS[@]}")
241
fi
242
if [[ "${#sizes[@]}" -eq 0 ]] ; then
243
sizes=("${SIZE_VARIANTS[@]}")
244
fi
245
for color in "${colors[@]}"; do
246
for size in "${sizes[@]}"; do
247
install "${dest:-$DEST_DIR}" "${_name:-$THEME_NAME}" "$color" "$size"
248
done
249
done
250
251
if [[ "${gdm:-}" == 'true' ]]; then
252
install_gdm "${dest:-$DEST_DIR}" "${_name:-$THEME_NAME}" "$color" "$size"
253
fi
254
255
echo
256
echo "Done."
257