-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
wallhub.sh
executable file
·181 lines (152 loc) · 3.3 KB
/
wallhub.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/usr/bin/env bash
set -e
nested() {
export MUTTER_DEBUG_DUMMY_MODE_SPECS=1366x768
dbus-run-session -- gnome-shell --unsafe-mode --nested --wayland --no-x11
}
build() {
echo "Compiling..."
npm run compile
if [ "$1" = "release" ]; then
echo "Prettifying..."
npm run compile:padding 1>/dev/null
echo "Stripping debug values..."
sed 's/const DEBUG = true;/const DEBUG = false;/g' ./dist/compiled/utils/common/misc.js >./dist/compiled/utils/common/misc.js.tmp
mv ./dist/compiled/utils/common/misc.js.tmp ./dist/compiled/utils/common/misc.js
fi
cp src/metadata.json dist/compiled/metadata.json
cp src/stylesheet.css dist/compiled/stylesheet.css 2>/dev/null || :
echo "Packing..."
EXCLUDEFILES=("metadata.json" "extension.js" "prefs.js" "stylesheet.css")
EXCLUDEDIRS=("compiled")
JSSRCDIR="$PWD/dist/compiled"
BUILDDIR="$PWD/dist/builds"
FINDFARGS=()
for F in "${EXCLUDEFILES[@]}"; do
FINDFARGS+=("!" "-name" "$F")
done
FINDDARGS=()
for D in "${EXCLUDEDIRS[@]}"; do
FINDDARGS+=("!" "-name" "$D")
done
EXTRAFILES=$(find "$JSSRCDIR" -maxdepth 1 -type f "${FINDFARGS[@]}")
EXTRADIRS=$(find "$JSSRCDIR" -maxdepth 1 -type d "${FINDDARGS[@]}")
ESFLAGS=()
for F in $EXTRAFILES; do
ESFLAGS+=("--extra-source=$F")
done
for D in $EXTRADIRS; do
ESFLAGS+=("--extra-source=$D")
done
SCHEMA="$PWD/assets/org.gnome.shell.extensions.wallhub.gschema.xml"
PODIR="$PWD/assets/locale"
mkdir -p "$BUILDDIR"
gnome-extensions pack -f -o "$BUILDDIR" --schema="$SCHEMA" --podir="$PODIR" "${ESFLAGS[@]}" "$JSSRCDIR"
}
debug() {
echo "Debugging..."
build
install
nested
}
translations() {
echo "Updating translations..."
touch assets/locale/[email protected]
xgettext \
--from-code=UTF-8 \
--add-comments \
--join-existing \
--keyword=_ \
--keyword=C_:1c,2 \
--language=Javascript \
--output=assets/locale/[email protected] \
src/*.ts src/**/*.ts \
assets/ui/*.blp
}
reload() {
echo "Reloading..."
build
install
if [ "$XDG_SESSION_TYPE" = "x11" ]; then
pkill -HUP gnome-shell
else
echo "Reloading Wayland session is not supported yet."
fi
}
lint() {
echo "Linting..."
npm run lint
}
format() {
echo "Formatting..."
npm run format
}
install() {
echo "Installing..."
gnome-extensions install --force ./dist/builds/[email protected]
}
uninstall() {
echo "Uninstalling..."
gnome-extensions uninstall [email protected]
}
enable() {
echo "Enabling..."
gnome-extensions enable [email protected]
}
disable() {
echo "Disabling..."
gnome-extensions disable [email protected]
}
prefs() {
echo "Opening prefs..."
gnome-extensions prefs [email protected]
}
watch() {
echo "Watching for setting changes..."
dconf watch /org/gnome/shell/extensions/wallhub/
}
case "$1" in
release)
build "release"
;;
build)
build
;;
debug)
debug
;;
translations)
translations
;;
reload)
reload
;;
lint)
lint
;;
format)
format
;;
install)
install
;;
uninstall)
uninstall
;;
enable)
enable
;;
disable)
disable
;;
prefs)
prefs
;;
watch)
watch
;;
*)
echo "Usage: $0 {release|build|debug|translations|reload|lint|format|install|uninstall|enable|disable|prefs|watch}"
exit 1
;;
esac