forked from Nockiro/slack-black-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdarkSlack.sh
74 lines (59 loc) · 2.7 KB
/
darkSlack.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
#! /usr/bin/env bash
# Originally written by smitt04 in https://github.com/widget-/slack-black-theme/issues/98#issuecomment-511449693
# Extended for slack 3/4 recognition by Nockiro
OSX_SLACK_RESOURCES_DIR="/Applications/Slack.app/Contents/Resources"
LINUX_SLACK_RESOURCES_DIR="/usr/lib/slack/resources"
if [[ -d $OSX_SLACK_RESOURCES_DIR ]]; then SLACK_RESOURCES_DIR=$OSX_SLACK_RESOURCES_DIR; fi
if [[ -d $LINUX_SLACK_RESOURCES_DIR ]]; then SLACK_RESOURCES_DIR=$LINUX_SLACK_RESOURCES_DIR; fi
if [[ -z $SLACK_RESOURCES_DIR ]]; then
# First: Assume we are on wsl
SLACK_RESOURCES_DIR=$(wslpath $(cmd.exe /C "echo %LOCALAPPDATA%") | cut -d$'\r' -f1)
# If that didn't work, try a more generic approach for the bash
if [[ -z $SLACK_RESOURCES_DIR ]]; then
SLACK_RESOURCES_DIR=$(cmd.exe /C "cd /D %LOCALAPPDATA% && bash.exe -c pwd")
fi
# Find latest version installed
APP_VER=$(ls -dt ${SLACK_RESOURCES_DIR}/slack/app-[2-9]*)
set -- "$(echo $APP_VER)"
IFS='/' read -a APP_VER_ARR <<< "$1"
APP_VER=${APP_VER_ARR[-1]}
SLACK_RESOURCES_DIR="${SLACK_RESOURCES_DIR}/slack/${APP_VER}/resources"
echo $SLACK_RESOURCES_DIR
fi
# on "real" unix systems, there is no version number in the path - so we ask the user
if [ -z "$APP_VER" ]; then
read -p "Enter your slack version (only major, e.g, 4 or 3): " APP_VER
APP_VER="app-${APP_VER}"
fi
SLACK_FILE_PATH_3="${SLACK_RESOURCES_DIR}"/app.asar.unpacked/src/static/index.js
SLACK_FILE_PATH_3_1="${SLACK_RESOURCES_DIR}"/app.asar.unpacked/src/static/ssb-interop.js
SLACK_FILE_PATH_4="${SLACK_RESOURCES_DIR}"/app.asar.unpacked/dist/ssb-interop.bundle.js
echo "Got app version ${APP_VER}"
if [[ $APP_VER == app-4* ]]; then
echo "Updating Slack 4 code.."
# Check if commands exist
if ! command -v node >/dev/null 2>&1; then
echo "Node.js is not installed. Please install before continuing."
exit 1
fi
if ! command -v npm >/dev/null 2>&1; then
echo "npm is not installed. Please install before continuing."
exit 1
fi
if ! command -v npx >/dev/null 2>&1; then
echo "npx is not installed. run `npm i -g npx` to install."
exit 1
fi
echo ""
echo "This script requires sudo privileges." && echo "You'll need to provide your password."
sudo npx asar extract "${SLACK_RESOURCES_DIR}"/app.asar "${SLACK_RESOURCES_DIR}"/app.asar.unpacked
cat interjectCode.js | sudo tee -a "${SLACK_FILE_PATH_4}" > /dev/null
sudo npx asar pack "${SLACK_RESOURCES_DIR}"/app.asar.unpacked "${SLACK_RESOURCES_DIR}"/app.asar
fi
if [[ $APP_VER == app-3* ]]; then
echo "Updating Slack 3 code.."
cat interjectCode.js | sudo tee -a "${SLACK_FILE_PATH_3}" > /dev/null
cat interjectCode.js | sudo tee -a "${SLACK_FILE_PATH_3_1}" > /dev/null
fi
echo ""
echo "Slack Updated! Refresh or reload slack to see changes"