test.sh
Bourne-Again shell script, ASCII text executable
1
#!/bin/bash
2
#
3
# Once run the script, no need to run ./install.sh for testing. ;)
4
# Without an argument, this will install only normal variant.
5
# Valid arguments are:
6
#
7
# compact dark dark-compact light light-compact all uninstall
8
#
9
# FIXME: `unity` and `xfwm4` are not fully supported for now since `*.svg` link incorrect locales (with '-light' variant).
10
# FIXME: Multiple arguments should be allowed.
11
set -ueo pipefail
12
13
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
14
SRC_DIR="$REPO_DIR/src"
15
16
DEST_DIR="$HOME/.themes"
17
THEME_NAME="Materia.dev"
18
# shellcheck disable=SC2034 # will this be used later?
19
COLOR_VARIANTS=('' '-dark' '-light')
20
# shellcheck disable=SC2034 # will this be used later?
21
SIZE_VARIANTS=('' '-compact')
22
23
GTK_VERSIONS=('3.0')
24
GS_VERSIONS=('3.18' '3.24' '3.26' '3.28' '3.30')
25
LATEST_GS_VERSION="${GS_VERSIONS[-1]}"
26
27
# Set a proper gnome-shell theme version
28
if [[ "$(which gnome-shell 2> /dev/null)" ]]; then
29
CURRENT_GS_VERSION="$(gnome-shell --version | cut -d ' ' -f 3 | cut -d . -f -2)"
30
for version in "${GS_VERSIONS[@]}"; do
31
if (( "$(bc <<< "$CURRENT_GS_VERSION <= $version")" )); then
32
GS_VERSION="$version"
33
break
34
elif (( "$(bc <<< "$CURRENT_GS_VERSION > $LATEST_GS_VERSION")" )); then
35
GS_VERSION="$LATEST_GS_VERSION"
36
break
37
fi
38
done
39
else
40
GS_VERSION="$LATEST_GS_VERSION"
41
fi
42
43
test() {
44
local color="$1"
45
local size="$2"
46
47
[[ "$color" == '-dark' ]] && local ELSE_DARK="$color"
48
[[ "$color" == '-light' ]] && local ELSE_LIGHT="$color"
49
50
local THEME_DIR="${DEST_DIR:?}/$THEME_NAME$color$size"
51
52
# SC2115: Protect /.
53
[[ -d "$THEME_DIR" ]] && rm -rf "${THEME_DIR:?}"
54
55
mkdir -p "$THEME_DIR"
56
ln -sT "$SRC_DIR/index$color$size.theme" "$THEME_DIR/index.theme"
57
58
mkdir -p "$THEME_DIR/cinnamon"
59
ln -s "$SRC_DIR/cinnamon/assets" "$THEME_DIR/cinnamon"
60
ln -s "$SRC_DIR/cinnamon/thumbnail.png" "$THEME_DIR/cinnamon"
61
ln -sT "$SRC_DIR/cinnamon/cinnamon$color$size.css" "$THEME_DIR/cinnamon/cinnamon.css"
62
63
mkdir -p "$THEME_DIR/gnome-shell"
64
ln -s "$SRC_DIR/gnome-shell/"{extensions,pad-osd.css,process-working.svg} "$THEME_DIR/gnome-shell"
65
ln -sT "$SRC_DIR/gnome-shell/assets${ELSE_DARK:-}" "$THEME_DIR/gnome-shell/assets"
66
ln -sT "$SRC_DIR/gnome-shell/$GS_VERSION/gnome-shell$color$size.css" "$THEME_DIR/gnome-shell/gnome-shell.css"
67
68
mkdir -p "$THEME_DIR/gtk-2.0"
69
ln -s "$SRC_DIR/gtk-2.0/"{apps.rc,hacks.rc,main.rc} "$THEME_DIR/gtk-2.0"
70
ln -sT "$SRC_DIR/gtk-2.0/assets${ELSE_DARK:-}" "$THEME_DIR/gtk-2.0/assets"
71
ln -sT "$SRC_DIR/gtk-2.0/gtkrc$color" "$THEME_DIR/gtk-2.0/gtkrc"
72
73
for version in "${GTK_VERSIONS[@]}"; do
74
mkdir -p "$THEME_DIR/gtk-$version"
75
ln -s "$SRC_DIR/gtk/assets" "$THEME_DIR/gtk-$version"
76
ln -sT "$SRC_DIR/gtk/$version/gtk$color$size.css" "$THEME_DIR/gtk-$version/gtk.css"
77
[[ "$color" != '-dark' ]] && \
78
ln -sT "$SRC_DIR/gtk/$version/gtk-dark$size.css" "$THEME_DIR/gtk-$version/gtk-dark.css"
79
done
80
81
mkdir -p "$THEME_DIR/metacity-1"
82
ln -s "$SRC_DIR/metacity-1/"{assets,metacity-theme-3.xml} "$THEME_DIR/metacity-1"
83
ln -sT "$SRC_DIR/metacity-1/metacity-theme-2${ELSE_LIGHT:-}.xml" "$THEME_DIR/metacity-1/metacity-theme-2.xml"
84
85
mkdir -p "$THEME_DIR/unity"
86
ln -s "$SRC_DIR/unity/"{*.svg,*.png,dash-widgets.json} "$THEME_DIR/unity"
87
ln -sT "$SRC_DIR/unity/assets${ELSE_LIGHT:-}" "$THEME_DIR/unity/assets"
88
89
mkdir -p "$THEME_DIR/xfwm4"
90
ln -s "$SRC_DIR/xfwm4/"{*.svg,themerc} "$THEME_DIR/xfwm4"
91
ln -sT "$SRC_DIR/xfwm4/assets${ELSE_LIGHT:-}" "$THEME_DIR/xfwm4/assets"
92
93
echo "Installed to '$THEME_DIR'"
94
}
95
96
case "${1:-}" in
97
"")
98
test '' ''
99
;;
100
compact)
101
test '' '-compact'
102
;;
103
dark)
104
test '-dark' ''
105
;;
106
dark-compact)
107
test '-dark' '-compact'
108
;;
109
light)
110
test '-light' ''
111
;;
112
light-compact)
113
test '-light' '-compact'
114
;;
115
all)
116
test '' ''
117
test '' '-compact'
118
test '-dark' ''
119
test '-dark' '-compact'
120
test '-light' ''
121
test '-light' '-compact'
122
;;
123
uninstall)
124
# SC2115: Protect /.
125
rm -rf "${DEST_DIR:?}/$THEME_NAME"{,-compact,-dark,-dark-compact,-light,-light-compact}
126
;;
127
*)
128
echo "Invalid argument: '${1:-}'"
129
echo "Valid arguments are: 'compact' 'dark' 'dark-compact' 'light' 'light-compact' 'all' 'uninstall'"
130
;;
131
esac
132