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