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 • 8.97 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.18' '3.20' '3.22')
14
GS_VERSIONS=('3.18' '3.24' '3.26' '3.28' '3.30')
15
LATEST_GS_VERSION="${GS_VERSIONS[-1]}"
16
17
# Set a proper gnome-shell theme version
18
if [[ "$(which gnome-shell 2> /dev/null)" ]]; then
19
CURRENT_GS_VERSION="$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -2)"
20
for version in "${GS_VERSIONS[@]}"; do
21
if (( "$(bc <<< "$CURRENT_GS_VERSION <= $version")" )); then
22
GS_VERSION="$version"
23
break
24
elif (( "$(bc <<< "$CURRENT_GS_VERSION > $LATEST_GS_VERSION")" )); then
25
GS_VERSION="$LATEST_GS_VERSION"
26
break
27
fi
28
done
29
else
30
GS_VERSION="$LATEST_GS_VERSION"
31
fi
32
33
usage() {
34
cat << EOF
35
Usage: $0 [OPTION]...
36
37
OPTIONS:
38
-d, --dest DIR Specify theme destination directory (Default: $DEST_DIR)
39
-n, --name NAME Specify theme name (Default: $THEME_NAME)
40
-c, --color VARIANT... Specify theme color variant(s) [standard|dark|light] (Default: All variants)
41
-s, --size VARIANT Specify theme size variant [standard|compact] (Default: All variants)
42
-g, --gdm Install GDM theme
43
-h, --help Show this help
44
45
INSTALLATION EXAMPLES:
46
Install all theme variants into ~/.themes
47
$0 --dest ~/.themes
48
Install all theme variants including GDM theme
49
$0 --gdm
50
Install standard theme variant only
51
$0 --color standard --size standard
52
Install specific theme variants with different name into ~/.themes
53
$0 --dest ~/.themes --name MyTheme --color light dark --size compact
54
EOF
55
}
56
57
install() {
58
local dest="$1"
59
local name="$2"
60
local color="$3"
61
local size="$4"
62
63
[[ "$color" == '-dark' ]] && local ELSE_DARK="$color"
64
[[ "$color" == '-light' ]] && local ELSE_LIGHT="$color"
65
66
local THEME_DIR="$dest/$name$color$size"
67
68
# SC2115: Protect /.
69
[[ -d "$THEME_DIR" ]] && rm -rf "${THEME_DIR:?}"
70
71
echo "Installing '$THEME_DIR'..."
72
73
mkdir -p "$THEME_DIR"
74
cp -r "$REPO_DIR/COPYING" "$THEME_DIR"
75
cp -r "$SRC_DIR/index$color$size.theme" "$THEME_DIR/index.theme"
76
77
mkdir -p "$THEME_DIR/chrome"
78
cp -r "$SRC_DIR/chrome/chrome-theme$color.crx" "$THEME_DIR/chrome/chrome-theme.crx"
79
cp -r "$SRC_DIR/chrome/chrome-scrollbar${ELSE_DARK:-}.crx" "$THEME_DIR/chrome/chrome-scrollbar.crx"
80
81
mkdir -p "$THEME_DIR/cinnamon"
82
cp -r "$SRC_DIR/cinnamon/assets" "$THEME_DIR/cinnamon"
83
cp -r "$SRC_DIR/cinnamon/thumbnail.png" "$THEME_DIR/cinnamon"
84
cp -r "$SRC_DIR/cinnamon/cinnamon$color$size.css" "$THEME_DIR/cinnamon/cinnamon.css"
85
86
mkdir -p "$THEME_DIR/gnome-shell"
87
cp -r "$SRC_DIR/gnome-shell/"{*.svg,extensions,noise-texture.png,pad-osd.css} "$THEME_DIR/gnome-shell"
88
cp -r "$SRC_DIR/gnome-shell/gnome-shell-theme.gresource.xml" "$THEME_DIR/gnome-shell"
89
cp -r "$SRC_DIR/gnome-shell/assets${ELSE_DARK:-}" "$THEME_DIR/gnome-shell/assets"
90
cp -r "$SRC_DIR/gnome-shell/$GS_VERSION/gnome-shell$color$size.css" "$THEME_DIR/gnome-shell/gnome-shell.css"
91
92
mkdir -p "$THEME_DIR/gtk-2.0"
93
cp -r "$SRC_DIR/gtk-2.0/"{apps.rc,hacks.rc,main.rc} "$THEME_DIR/gtk-2.0"
94
cp -r "$SRC_DIR/gtk-2.0/assets${ELSE_DARK:-}" "$THEME_DIR/gtk-2.0/assets"
95
cp -r "$SRC_DIR/gtk-2.0/gtkrc$color" "$THEME_DIR/gtk-2.0/gtkrc"
96
97
cp -r "$SRC_DIR/gtk/assets" "$THEME_DIR/gtk-assets"
98
99
for version in "${GTK_VERSIONS[@]}"; do
100
if [[ "$version" == '3.18' ]]; then
101
mkdir -p "$THEME_DIR/gtk-3.0"
102
ln -s ../gtk-assets "$THEME_DIR/gtk-3.0/assets"
103
cp -r "$SRC_DIR/gtk/$version/gtk$color.css" "$THEME_DIR/gtk-3.0/gtk.css"
104
[[ "$color" != '-dark' ]] && \
105
cp -r "$SRC_DIR/gtk/$version/gtk-dark.css" "$THEME_DIR/gtk-3.0/gtk-dark.css"
106
else
107
mkdir -p "$THEME_DIR/gtk-$version"
108
ln -s ../gtk-assets "$THEME_DIR/gtk-$version/assets"
109
cp -r "$SRC_DIR/gtk/$version/gtk$color$size.css" "$THEME_DIR/gtk-$version/gtk.css"
110
[[ "$color" != '-dark' ]] && \
111
cp -r "$SRC_DIR/gtk/$version/gtk-dark$size.css" "$THEME_DIR/gtk-$version/gtk-dark.css"
112
fi
113
done
114
115
mkdir -p "$THEME_DIR/metacity-1"
116
cp -r "$SRC_DIR/metacity-1/"{assets,metacity-theme-3.xml} "$THEME_DIR/metacity-1"
117
cp -r "$SRC_DIR/metacity-1/metacity-theme-2${ELSE_LIGHT:-}.xml" "$THEME_DIR/metacity-1/metacity-theme-2.xml"
118
119
mkdir -p "$THEME_DIR/unity"
120
cp -r "$SRC_DIR/unity/"{*.svg,*.png,dash-widgets.json} "$THEME_DIR/unity"
121
cp -r "$SRC_DIR/unity/assets${ELSE_LIGHT:-}" "$THEME_DIR/unity/assets"
122
123
mkdir -p "$THEME_DIR/xfwm4"
124
cp -r "$SRC_DIR/xfwm4/"{*.svg,themerc} "$THEME_DIR/xfwm4"
125
cp -r "$SRC_DIR/xfwm4/assets${ELSE_LIGHT:-}" "$THEME_DIR/xfwm4/assets"
126
}
127
128
# Bakup and install files related to GDM theme
129
install_gdm() {
130
local THEME_DIR="$1/$2$3$4"
131
local GS_THEME_FILE="/usr/share/gnome-shell/gnome-shell-theme.gresource"
132
local UBUNTU_THEME_FILE="/usr/share/gnome-shell/theme/ubuntu.css"
133
134
if [[ -f "$GS_THEME_FILE" ]] && [[ "$(which glib-compile-resources 2> /dev/null)" ]]; then
135
echo "Installing '$GS_THEME_FILE'..."
136
cp -an "$GS_THEME_FILE" "$GS_THEME_FILE.bak"
137
glib-compile-resources \
138
--sourcedir="$THEME_DIR/gnome-shell" \
139
--target="$GS_THEME_FILE" \
140
"$THEME_DIR/gnome-shell/gnome-shell-theme.gresource.xml"
141
else
142
echo
143
echo "ERROR: Failed to install '$GS_THEME_FILE'"
144
exit 1
145
fi
146
147
if [[ -f "$UBUNTU_THEME_FILE" ]]; then
148
echo "Installing '$UBUNTU_THEME_FILE'..."
149
cp -an "$UBUNTU_THEME_FILE" "$UBUNTU_THEME_FILE.bak"
150
cp -af "$THEME_DIR/gnome-shell/gnome-shell.css" "$UBUNTU_THEME_FILE"
151
fi
152
}
153
154
while [[ "$#" -gt 0 ]]; do
155
case "${1:-}" in
156
-d|--dest)
157
dest="$2"
158
if [[ ! -d "$dest" ]]; then
159
echo "ERROR: Destination directory does not exist."
160
exit 1
161
fi
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
for color in "${colors[@]:-${COLOR_VARIANTS[@]}}"; do
240
for size in "${sizes[@]:-${SIZE_VARIANTS[@]}}"; do
241
install "${dest:-$DEST_DIR}" "${_name:-$THEME_NAME}" "$color" "$size"
242
done
243
done
244
245
if [[ "${gdm:-}" == 'true' ]]; then
246
install_gdm "${dest:-$DEST_DIR}" "${_name:-$THEME_NAME}" "$color" "$size"
247
fi
248
249
echo
250
echo "Done."
251