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