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