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 • 7.99 kiB
Bourne-Again shell script, ASCII text executable
        
            
1
#!/bin/bash
2
#set -ueo pipefail
3
#set -x
4
5
DEST_DIR=/usr/share/themes
6
THEME_NAME=Materia
7
COLOR_VARIANTS=('' '-dark' '-light')
8
SIZE_VARIANTS=('' '-compact')
9
10
GTK_VERSIONS=('3.18' '3.20' '3.22')
11
GS_VERSIONS=('3.18' '3.20' '3.22' '3.24' '3.26')
12
LATEST_GS_VERSION=${GS_VERSIONS[@]: -1}
13
14
# Set a proper gnome-shell theme version
15
if [[ $(which gnome-shell 2> /dev/null) ]]; then
16
CURRENT_GS_VERSION=$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -2)
17
for version in "${GS_VERSIONS[@]}"; do
18
if (( $(echo "$CURRENT_GS_VERSION <= $version" | bc) )); then
19
GS_VERSION=${version}
20
break
21
elif (( $(echo "$CURRENT_GS_VERSION > $LATEST_GS_VERSION" | bc) )); then
22
GS_VERSION=${LATEST_GS_VERSION}
23
break
24
fi
25
done
26
else
27
GS_VERSION=${LATEST_GS_VERSION}
28
fi
29
30
usage() {
31
printf "%s\n" "Usage: $0 [OPTIONS...]"
32
printf "\n%s\n" "OPTIONS:"
33
printf " %-25s%s\n" "-d, --dest DIR" "Specify theme destination directory (Default: ${DEST_DIR})"
34
printf " %-25s%s\n" "-n, --name NAME" "Specify theme name (Default: ${THEME_NAME})"
35
printf " %-25s%s\n" "-c, --color VARIANTS..." "Specify theme color variant(s) [standard|dark|light] (Default: All variants)"
36
printf " %-25s%s\n" "-s, --size VARIANT" "Specify theme size variant [standard|compact] (Default: All variants)"
37
printf " %-25s%s\n" "-h, --help" "Show this help"
38
printf "\n%s\n" "INSTALLATION EXAMPLES:"
39
printf "%s\n" "Install all theme variants into ~/.themes"
40
printf " %s\n" "$0 --dest ~/.themes"
41
printf "%s\n" "Install standard theme variant only"
42
printf " %s\n" "$0 --color standard --size standard"
43
printf "%s\n" "Install specific theme variants with different name into ~/.themes"
44
printf " %s\n" "$0 --dest ~/.themes --name MyTheme --color light dark --size compact"
45
}
46
47
install() {
48
local dest=${1}
49
local name=${2}
50
local color=${3}
51
local size=${4}
52
53
[[ ${color} == '-dark' ]] && local ELSE_DARK=${color}
54
[[ ${color} == '-light' ]] && local ELSE_LIGHT=${color}
55
56
local THEME_DIR=${dest}/${name}${color}${size}
57
58
[[ -d ${THEME_DIR} ]] && rm -rf ${THEME_DIR}
59
60
echo "Installing '${THEME_DIR}'..."
61
62
mkdir -p ${THEME_DIR}
63
cp -ur COPYING ${THEME_DIR}
64
cp -ur src/index${color}${size}.theme ${THEME_DIR}/index.theme
65
66
mkdir -p ${THEME_DIR}/chrome
67
cp -ur src/chrome/chrome-theme${color}.crx ${THEME_DIR}/chrome/chrome-theme.crx
68
cp -ur src/chrome/chrome-scrollbar${ELSE_DARK}.crx ${THEME_DIR}/chrome/chrome-scrollbar.crx
69
70
mkdir -p ${THEME_DIR}/gnome-shell
71
cp -ur src/gnome-shell/${GS_VERSION}/*.svg ${THEME_DIR}/gnome-shell
72
cp -urL src/gnome-shell/${GS_VERSION}/{extensions,noise-texture.png,pad-osd.css} ${THEME_DIR}/gnome-shell
73
cp -urL src/gnome-shell/${GS_VERSION}/assets${ELSE_DARK} ${THEME_DIR}/gnome-shell/assets
74
cp -ur src/gnome-shell/${GS_VERSION}/gnome-shell${color}${size}.css ${THEME_DIR}/gnome-shell/gnome-shell.css
75
glib-compile-resources \
76
--sourcedir=${THEME_DIR}/gnome-shell \
77
--target=${THEME_DIR}/gnome-shell/gnome-shell-theme.gresource \
78
src/gnome-shell/${GS_VERSION}/gnome-shell-theme.gresource.xml
79
80
mkdir -p ${THEME_DIR}/gtk-2.0
81
cp -ur src/gtk-2.0/{apps.rc,hacks.rc,main.rc} ${THEME_DIR}/gtk-2.0
82
cp -ur src/gtk-2.0/assets${ELSE_DARK} ${THEME_DIR}/gtk-2.0/assets
83
cp -ur src/gtk-2.0/gtkrc${color} ${THEME_DIR}/gtk-2.0/gtkrc
84
85
mkdir -p ${THEME_DIR}/gtk-common
86
cp -ur src/gtk-3.0/gtk-common/assets ${THEME_DIR}/gtk-common
87
88
for version in "${GTK_VERSIONS[@]}"; do
89
if [[ ${version} == '3.18' ]]; then
90
mkdir -p ${THEME_DIR}/gtk-3.0
91
cp -ur src/gtk-3.0/${version}/assets ${THEME_DIR}/gtk-3.0
92
cp -ur src/gtk-3.0/${version}/gtk${color}.css ${THEME_DIR}/gtk-3.0/gtk.css
93
[[ ${color} != '-dark' ]] && \
94
cp -ur src/gtk-3.0/${version}/gtk-dark.css ${THEME_DIR}/gtk-3.0/gtk-dark.css
95
else
96
mkdir -p ${THEME_DIR}/gtk-${version}
97
cp -ur src/gtk-3.0/${version}/assets ${THEME_DIR}/gtk-${version}
98
cp -ur src/gtk-3.0/${version}/gtk${color}${size}.css ${THEME_DIR}/gtk-${version}/gtk.css
99
[[ ${color} != '-dark' ]] && \
100
cp -ur src/gtk-3.0/${version}/gtk-dark${size}.css ${THEME_DIR}/gtk-${version}/gtk-dark.css
101
fi
102
done
103
104
mkdir -p ${THEME_DIR}/metacity-1
105
cp -ur src/metacity-1/assets ${THEME_DIR}/metacity-1
106
cp -ur src/metacity-1/metacity-theme-2${ELSE_LIGHT}.xml ${THEME_DIR}/metacity-1/metacity-theme-2.xml
107
cp -ur src/metacity-1/metacity-theme-3${ELSE_LIGHT}.xml ${THEME_DIR}/metacity-1/metacity-theme-3.xml
108
109
mkdir -p ${THEME_DIR}/unity
110
cp -ur src/unity/{*.svg,*.png,dash-widgets.json} ${THEME_DIR}/unity
111
cp -ur src/unity/assets${ELSE_LIGHT} ${THEME_DIR}/unity/assets
112
113
mkdir -p ${THEME_DIR}/xfwm4
114
cp -ur src/xfwm4/{*.svg,themerc} ${THEME_DIR}/xfwm4
115
cp -ur src/xfwm4/assets${ELSE_LIGHT} ${THEME_DIR}/xfwm4/assets
116
}
117
118
while [[ $# -gt 0 ]]; do
119
case "${1}" in
120
-d|--dest)
121
dest="${2}"
122
if [[ ! -d "${dest}" ]]; then
123
echo "ERROR: Destination directory does not exist."
124
exit 1
125
fi
126
shift 2
127
;;
128
-n|--name)
129
name="${2}"
130
shift 2
131
;;
132
-c|--color)
133
shift
134
for variant in "${@}"; do
135
case "${variant}" in
136
standard)
137
colors+=("${COLOR_VARIANTS[0]}")
138
shift
139
;;
140
dark)
141
colors+=("${COLOR_VARIANTS[1]}")
142
shift
143
;;
144
light)
145
colors+=("${COLOR_VARIANTS[2]}")
146
shift
147
;;
148
-*|--*)
149
break
150
;;
151
*)
152
echo "ERROR: Unrecognized color variant '$1'."
153
echo "Try '$0 --help' for more information."
154
exit 1
155
;;
156
esac
157
done
158
;;
159
-s|--size)
160
shift
161
for variant in "${@}"; do
162
case "${variant}" in
163
standard)
164
sizes+=("${SIZE_VARIANTS[0]}")
165
shift
166
;;
167
compact)
168
sizes+=("${SIZE_VARIANTS[1]}")
169
shift
170
;;
171
-*|--*)
172
break
173
;;
174
*)
175
echo "ERROR: Unrecognized size variant '$1'."
176
echo "Try '$0 --help' for more information."
177
exit 1
178
;;
179
esac
180
done
181
;;
182
-h|--help)
183
usage
184
exit 0
185
;;
186
*)
187
echo "ERROR: Unrecognized installation option '$1'."
188
echo "Try '$0 --help' for more information."
189
exit 1
190
;;
191
esac
192
done
193
194
if [[ ! -w "${dest:-${DEST_DIR}}" ]]; then
195
echo "Please run as root."
196
exit 1
197
fi
198
199
for color in "${colors[@]:-${COLOR_VARIANTS[@]}}"; do
200
for size in "${sizes[@]:-${SIZE_VARIANTS[@]}}"; do
201
install "${dest:-${DEST_DIR}}" "${name:-${THEME_NAME}}" "${color}" "${size}"
202
done
203
done
204
205
echo
206
echo Done.
207