-
Notifications
You must be signed in to change notification settings - Fork 25
/
slack-theme
executable file
·445 lines (396 loc) · 13.6 KB
/
slack-theme
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
#!/bin/bash
function show_usage() {
echo "
NAME
slack-theme
SYNOPSIS
slack-theme
slack-theme day
slack-theme night
slack-theme night-mono
slack-theme aubergine
slack-theme aubergine-mono
slack-theme arc-dark
slack-theme midnight-blue
slack-theme midnight-blue-mono
slack-theme solarized-dark
slack-theme solarized-light
slack-theme install
slack-theme uninstall
DESCRIPTION
Change Slack Colors
COMMANDS
day
Revert to Day Mode
night
Use Black CSS
night-mono
Use Night-Mono CSS
aubergine
Use Aubergine CSS
aubergine-mono
Use Aubergine-Mono CSS
arc-dark
Use Arc-Dark CSS
midnight-blue
Use Midnight-Blue CSS
midnight-blue-mono
Use Midnight-Blue-Mono CSS
solarized-dark
Use Solarized-Dark CSS
solarized-light
Use Solarized-Light CSS
install
Download necessary scripts
uninstall
Remove this tool from System
Report any bugs to mykehell123@gmail.com
"
}
INSTALL_DIR="$HOME/bin/slack-theme"
CSS_URL="https://raw.githubusercontent.com/laCour/slack-night-mode/master"
ARC_DARK_FILE="arc-dark.css"
AUBERGINE_FILE="aubergine.css"
AUBERGINE_MONO_FILE="aubergine-monospaced.css"
BLACK_FILE="black.css"
BLACK_MONO_FILE="black-monospaced.css"
MIDNIGHT_BLUE_FILE="midnight-blue.css"
MIDNIGHT_BLUE_MONO_FILE="midnight-blue-monospaced.css"
SOLARIZED_DARK_FILE="solarized-dark.css"
SOLARIZED_LIGHT_FILE="solarized-light.css"
ARC_DARK_URL="$CSS_URL/css/raw/variants/$ARC_DARK_FILE"
AUBERGINE_URL="$CSS_URL/css/raw/variants/$AUBERGINE_FILE"
AUBERGINE_MONO_URL="$CSS_URL/css/raw/variants/$AUBERGINE_MONO_FILE"
BLACK_URL="$CSS_URL/css/raw/$BLACK_FILE"
BLACK_MONO_URL="$CSS_URL/css/raw/variants/$BLACK_MONO_FILE"
MIDNIGHT_BLUE_URL="$CSS_URL/css/raw/variants/$MIDNIGHT_BLUE_FILE"
MIDNIGHT_BLUE_MONO_URL="$CSS_URL/css/raw/variants/$MIDNIGHT_BLUE_MONO_FILE"
SOLARIZED_DARK_URL="$CSS_URL/css/raw/variants/$SOLARIZED_DARK_FILE"
SOLARIZED_LIGHT_URL="$CSS_URL/css/raw/variants/$SOLARIZED_LIGHT_FILE"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
BACKUP_FOLDER="$DIR/backup"
BACKUP_FILE="$BACKUP_FOLDER/ssb-interop.js"
if [ "$(uname -r | sed -n 's/.*\( *Microsoft *\).*/\1/p')" == "Microsoft" ] # Windows OS
then
OS="windows"
INTEROP_FILE_ROOT="$(cmd.exe /c 'echo|set /p=%LOCALAPPDATA%' | sed -n 's/\\/\//pg' | sed -n 's/C:/\/mnt\/c/p')/slack"
LATEST_APP_DIR="$(ls -t ${INTEROP_FILE_ROOT} | grep 'app-[0-9]' | head -n1)"
INTEROP_FILE="${INTEROP_FILE_ROOT}/${LATEST_APP_DIR}/resources/app.asar.unpacked/src/static/ssb-interop.js"
EXE_FILE="${INTEROP_FILE_ROOT}/slack.exe"
if [ ! -f "$INTEROP_FILE" ]
then
IS_VERSION_4=true
INTEROP_FOLDER="${INTEROP_FOLDER_ROOT}/slack/${LATEST_APP_DIR}/resources/app.asar.unpacked/dist/ssb-interop.bundle.js"
ASAR_FILE="${INTEROP_FOLDER_ROOT}/slack/${LATEST_APP_DIR}/resources/app.asar"
BACKUP_FILE="$BACKUP_FOLDER/ssb-interop.bundle.js"
ASAR="$DIR/bin/asar"
ASAR_REMOTE="https://raw.githubusercontent.com/mykeels/asar-binaries/master/bin/asar-win.exe"
BACKUP_FILE_REMOTE="https://raw.githubusercontent.com/mykeels/slack-theme-cli/master/backup/v4.0/ssb-interop.bundle.js"
fi
elif [ "$(uname)" == "Linux" ] # Linux OS
then
INTEROP_FILE="/usr/lib/slack/resources/app.asar.unpacked/src/static/ssb-interop.js"
elif [ "$(uname)" == "Darwin" ] # Mac OS
then
INTEROP_FILE="/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js"
if [ ! -f "$INTEROP_FILE" ]
then
IS_VERSION_4=true
INTEROP_FILE="$DIR/files/app.asar.unpacked/dist/ssb-interop.bundle.js"
ASAR_FILE="/Applications/Slack.app/Contents/Resources/app.asar"
BACKUP_FILE="$BACKUP_FOLDER/ssb-interop.bundle.js"
ASAR="$DIR/bin/asar"
ASAR_REMOTE="https://raw.githubusercontent.com/mykeels/asar-binaries/master/bin/asar-macos"
BACKUP_FILE_REMOTE="https://raw.githubusercontent.com/mykeels/slack-theme-cli/master/backup/v4.0/ssb-interop.bundle.js"
fi
fi
if [ -z "$SLACK_THEME_SHELL_PROFILE" ]
then
SLACK_THEME_SHELL_PROFILE=~/".bash_profile" # Mac OS
if [ "$(uname)" == "Linux" ] # Linux OS
then
SLACK_THEME_SHELL_PROFILE=~/".profile"
fi
else
echo "sh: $SLACK_THEME_SHELL_PROFILE"
fi
# exit if no argument is specified
if [ -z "$1" ]
then
show_usage
exit 0
fi
function pull-css() {
mkdir -p css
curl $ARC_DARK_URL -O && mv $ARC_DARK_FILE "$DIR/css/$ARC_DARK_FILE"
curl $AUBERGINE_URL -O && mv $AUBERGINE_FILE "$DIR/css/$AUBERGINE_FILE"
curl $AUBERGINE_MONO_URL -O && mv $AUBERGINE_MONO_FILE "$DIR/css/$AUBERGINE_MONO_FILE"
curl $BLACK_URL -O && mv $BLACK_FILE "$DIR/css/$BLACK_FILE"
curl $BLACK_MONO_URL -O && mv $BLACK_MONO_FILE "$DIR/css/$BLACK_MONO_FILE"
curl $MIDNIGHT_BLUE_URL -O && mv $MIDNIGHT_BLUE_FILE "$DIR/css/$MIDNIGHT_BLUE_FILE"
curl $MIDNIGHT_BLUE_MONO_URL -O && mv $MIDNIGHT_BLUE_MONO_FILE "$DIR/css/$MIDNIGHT_BLUE_MONO_FILE"
curl $SOLARIZED_DARK_URL -O && mv $SOLARIZED_DARK_FILE "$DIR/css/$SOLARIZED_DARK_FILE"
curl $SOLARIZED_LIGHT_URL -O && mv $SOLARIZED_LIGHT_FILE "$DIR/css/$SOLARIZED_LIGHT_FILE"
}
function set-env-vars() {
if [ -z "$(cat $SLACK_THEME_SHELL_PROFILE | grep "PATH=\$PATH:$INSTALL_DIR")" ]
then
if [ ! -f "$SLACK_THEME_SHELL_PROFILE" ]; then
mkdir -p "`dirname \"$SLACK_THEME_SHELL_PROFILE\"`" 2>/dev/null
fi
echo "export PATH=\$PATH:$INSTALL_DIR" >> "$SLACK_THEME_SHELL_PROFILE"
if [ "$SLACK_THEME_SHELL_PROFILE" != "~/.bash_profile" ]
then
echo "export SLACK_THEME_SHELL_PROFILE=\"$SLACK_THEME_SHELL_PROFILE\"" >> "$SLACK_THEME_SHELL_PROFILE"
fi
fi
}
# install
if [ "$1" == "install" ]
then
mkdir -p "$HOME/bin"
mkdir -p $INSTALL_DIR
mkdir -p "$INSTALL_DIR/bin"
mkdir -p "$INSTALL_DIR/backup"
# ensure files are in installation directory
if [ ! -f "$INSTALL_DIR/slack-theme" ]
then
cp "$DIR/slack-theme" "$INSTALL_DIR/slack-theme"
set-env-vars
cd $INSTALL_DIR
bash "$INSTALL_DIR/slack-theme" install
if [ -f "$HOME/slack-theme" ]
then
rm "$HOME/slack-theme"
fi
exit 0
fi
if [ ! -f "$INSTALL_DIR/bin/asar" ]
then
curl $ASAR_REMOTE -o "$INSTALL_DIR/bin/asar"
chmod 766 "$INSTALL_DIR/bin/asar"
fi
if [ $IS_VERSION_4 ]
then
curl $BACKUP_FILE_REMOTE -o "$INSTALL_DIR/backup/ssb-interop.bundle.js"
fi
curl https://raw.githubusercontent.com/mykeels/slack-theme-cli/master/slack-day -O
curl https://raw.githubusercontent.com/mykeels/slack-theme-cli/master/slack-night -O
chmod 766 "$DIR/slack-theme"
chmod 766 "$DIR/slack-day"
chmod 766 "$DIR/slack-night"
pull-css # pull all relevant css files
if [ "$(uname)" == "Linux" ]
then
chmod 666 "${INTEROP_FILE}"
fi
set-env-vars
echo "installed successfully"
exit 0
fi
# uninstall
if [ "$1" == "uninstall" ]
then
. "$INSTALL_DIR/slack-day"
rm "$INSTALL_DIR/slack-day"
rm "$INSTALL_DIR/slack-night"
rm -rf "$INSTALL_DIR/css"
rm -rf "$BACKUP_FOLDER"
if [ "$(uname)" == "Linux" ] # Linux OS
then
sed "/export PATH=\$PATH:${INSTALL_DIR//\//\\/}/d" "$SLACK_THEME_SHELL_PROFILE" -i
sed "/export SLACK_THEME_SHELL_PROFILE=/d" "$SLACK_THEME_SHELL_PROFILE" -i
elif [ "$(uname)" == "Darwin" ] # Mac OS
then
sed -i '' "/export PATH=\$PATH:${INSTALL_DIR//\//\\/}/g" "$SLACK_THEME_SHELL_PROFILE"
sed -i '' "/export SLACK_THEME_SHELL_PROFILE=/g" "$SLACK_THEME_SHELL_PROFILE"
fi
rm -rf "$INSTALL_DIR"
echo "uninstalled successfully"
exit 0
fi
if [ "$1" == "pull-css" ]
then
pull-css
exit 0
fi
if [ "$1" == "day" ]
then
. "$DIR/slack-day"
exit 0
fi
BG_COLOR="#222"
THREAD_COLOR="#e6e6e6"
THREAD_BG_COLOR="#545454"
THREAD_BORDER_COLOR="#363636"
if [ "$1" == "night" ]
then
CSS_CONTENT=$(cat "$DIR/css/$BLACK_FILE")
fi
if [ "$1" == "night-mono" ]
then
CSS_CONTENT=$(cat "$DIR/css/$BLACK_MONO_FILE")
fi
if [ "$1" == "aubergine" ]
then
CSS_CONTENT=$(cat "$DIR/css/$AUBERGINE_FILE")
BG_COLOR="#3e313c"
THREAD_COLOR="#f0d9ed"
THREAD_BG_COLOR="#61485e"
THREAD_BORDER_COLOR="#4a3b49"
fi
if [ "$1" == "aubergine-mono" ]
then
CSS_CONTENT=$(cat "$DIR/css/$AUBERGINE_MONO_FILE")
BG_COLOR="#3e313c"
THREAD_COLOR="#f0d9ed"
THREAD_BG_COLOR="#61485e"
THREAD_BORDER_COLOR="#4a3b49"
fi
if [ "$1" == "arc-dark" ]
then
CSS_CONTENT=$(cat "$DIR/css/$ARC_DARK_FILE")
fi
if [ "$1" == "midnight-blue" ]
then
CSS_CONTENT=$(cat "$DIR/css/$MIDNIGHT_BLUE_FILE")
BG_COLOR="#000"
THREAD_COLOR="#00b9f2"
fi
if [ "$1" == "midnight-blue-mono" ]
then
CSS_CONTENT=$(cat "$DIR/css/$MIDNIGHT_BLUE_MONO_FILE")
BG_COLOR="#000"
THREAD_COLOR="#00b9f2"
fi
if [ "$1" == "solarized-dark" ]
then
CSS_CONTENT=$(cat "$DIR/css/$SOLARIZED_DARK_FILE")
BG_COLOR="#002b36"
THREAD_COLOR="#a1adad"
THREAD_BG_COLOR="#003340"
THREAD_BORDER_COLOR="#002b36"
fi
if [ "$1" == "solarized-light" ]
then
CSS_CONTENT=$(cat "$DIR/css/$SOLARIZED_LIGHT_FILE")
BG_COLOR="#fdf6e3"
THREAD_COLOR="#586e75"
THREAD_BG_COLOR="#fef9ed"
THREAD_BORDER_COLOR="#fdf6e3"
fi
if [ -z "$CSS_CONTENT" ]
then
echo "invalid command"
exit 1
fi
if [ -z "$ADDENDUM" ]
then
ADDENDUM=".menu ul li a:not(.inline_menu_link) {color: #fff !important;}
.p-threads_footer__input .p-message_input_field {background: $THREAD_BG_COLOR; border-color: $THREAD_BORDER_COLOR; color: $THREAD_COLOR;}
.p-threads_footer__input .p-message_input_file_button:not(:hover) { border-color: $THREAD_BORDER_COLOR; }
.p-threads_footer__input .p-message_input_file_button { background-color: $THREAD_BG_COLOR !important; }
.p-prefs_modal__radiogroup .p-prefs_modal__radio_decorator,
.c-button-unstyled.c-fullscreen_modal__close,
.c-fullscreen_modal__header, .c-fullscreen_modal__content,
.c-fullscreen_modal__body, .p-threads_view,
.p-threads_view__default_background,
.p-threads_view:not(.loading)::before { background: $BG_COLOR; color: $THREAD_COLOR; }
.p-threads_view__divider_line { border-top: 1px solid $THREAD_BORDER_COLOR; }
.p-threads_view__divider_label { background: $THREAD_BG_COLOR; color: $THREAD_COLOR; }
.p-threads_view a.c-member_slug, .c-member_slug--link, .c-mrkdwn__subteam--link {
background: $THREAD_BORDER_COLOR;
border: 1px solid $THREAD_BG_COLOR;
color: $THREAD_COLOR;
}
.c-timestamp, .p-threads_view .p-threads_view_header__channel_name { color: $THREAD_COLOR; }
.p_threads_view_load_newer_button, .p_threads_view_load_older_button, .c-input_textarea {
background: rgba(255, 255, 255, 0.05);
border-color: $THREAD_BORDER_COLOR;
color: $THREAD_COLOR;
}
.p-threads_view_reply--new_reply {
background: $THREAD_BORDER_COLOR;
}
.c-link--button {
color: $THREAD_COLOR;
border: 1px solid $THREAD_BORDER_COLOR;
}
.c-button-unstyled.c-select_button {
color: $BG_COLOR;
}
.p-prefs_modal__notification_example, .c-label--with_formatted_text {
background: $BG_COLOR !important;
}
"
fi
NODE_SCRIPT="
/** slack-theme-cli */
document.addEventListener('DOMContentLoaded', function() {
const css = \`$CSS_CONTENT\`
const overrides = \`
code { background-color: #535353; color: #85c5ff; } /* Change color: to whatever font color you want */
.c-mrkdwn__pre, .c-mrkdwn__quote { background: #535353 !important; background-color: #535353 !important; }
$ADDENDUM
\`
let s = document.createElement('style');
s.type = 'text/css';
s.innerHTML = css + overrides;
document.head.appendChild(s);
});
"
if [ $IS_VERSION_4 ]
then
if [ ! -f $ASAR ]
then
echo "asar exec not found"
exit 1
fi
if [ ! -f "$INTEROP_FILE" ]
then
$ASAR extract $ASAR_FILE "$DIR/files/app.asar.unpacked"
fi
fi
if [ -f "$INTEROP_FILE" ]
then
mkdir -p "$DIR/backup" # create folder if it does not exist
if [ -z "$(cat "$INTEROP_FILE" | grep "slack-theme-cli")" ]
then
cp "$INTEROP_FILE" "$BACKUP_FOLDER" # copy file as backup
else
if [ -f "$BACKUP_FILE" ]
then
cp "$BACKUP_FILE" "$INTEROP_FILE"
else
echo "backup file not found: $BACKUP_FILE"
exit 1
fi
fi
echo "$NODE_SCRIPT" >> "$INTEROP_FILE" # append script to file
# restart slack
if [ "$OS" == "windows" ] # Windows OS
then
cmd.exe /c 'taskkill /F /IM slack.exe' &> /dev/null
$EXE_FILE </dev/null &>/dev/null & # start slack process in detached mode
elif [ "$(uname)" == "Linux" ] # Linux OS
then
if [ $(ps aux | grep -i slack | wc -l) -gt 1 ]
then
killall "slack" # kill all slack processes
fi
slack </dev/null &>/dev/null & # start slack process in detached mode
elif [ "$(uname)" == "Darwin" ] # Mac OS
then
if [ $IS_VERSION_4 ]
then
sudo $ASAR pack "$DIR/files/app.asar.unpacked" $ASAR_FILE
fi
if [ $(ps aux | grep -i Slack | wc -l) -gt 1 ]
then
killall "Slack" # kill all slack processes
fi
/Applications/Slack.app/Contents/MacOS/Slack </dev/null &>/dev/null & # start slack process in detached mode
fi
else
echo "file does not exist"
fi