Skip to content

Commit

Permalink
feat: support version 4.0 on mac #32
Browse files Browse the repository at this point in the history
  • Loading branch information
mykeels committed Jul 15, 2019
1 parent be9c33c commit ef93654
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
ssb-interop.js
test/
css/
addendum
addendum
bin/
files/
backup/
26 changes: 26 additions & 0 deletions slack-day
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@ then
elif [ "$(uname)" == "Darwin" ] # Mac OS
then
INTEROP_FOLDER="/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static"
if [ ! -d "$INTEROP_FOLDER" ]
then
IS_VERSION_4=true
INTEROP_FOLDER="$DIR/files/app.asar.unpacked/dist"
ASAR_FILE="/Applications/Slack.app/Contents/Resources/app.asar"
BACKUP_FILE="$BACKUP_FOLDER/ssb-interop.bundle.js"
ASAR="$DIR/bin/asar"
fi
fi

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 ./files/app.asar.unpacked
fi
fi

if [ -f "$BACKUP_FILE" ]
Expand All @@ -31,6 +53,10 @@ then
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 ./files/app.asar.unpacked $ASAR_FILE
fi
killall "Slack" # kill all slack processes
/Applications/Slack.app/Contents/MacOS/Slack </dev/null &>/dev/null & # start slack process in detached mode
fi
Expand Down
31 changes: 30 additions & 1 deletion slack-theme
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ then
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"
fi
fi

if [ -z "$SLACK_THEME_SHELL_PROFILE" ]
Expand Down Expand Up @@ -169,6 +177,8 @@ then
fi
exit 0
fi
mkdir -p "$DIR/bin"
curl https://raw.githubusercontent.com/mykeels/asar-binaries/master/bin/asar-macos -o "$DIR/bin/asar"
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"
Expand Down Expand Up @@ -338,6 +348,7 @@ then
fi

NODE_SCRIPT="
/** slack-theme-cli */
document.addEventListener('DOMContentLoaded', function() {
const css = \`$CSS_CONTENT\`
const overrides = \`
Expand All @@ -349,10 +360,24 @@ document.addEventListener('DOMContentLoaded', function() {
});
"

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 ./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 "DOMContentLoaded")" ]
if [ -z "$(cat "$INTEROP_FILE" | grep "slack-theme-cli")" ]
then
cp "$INTEROP_FILE" "$BACKUP_FOLDER" # copy file as backup
else
Expand All @@ -377,6 +402,10 @@ then
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 ./files/app.asar.unpacked $ASAR_FILE
fi
killall "Slack" # kill all slack processes
/Applications/Slack.app/Contents/MacOS/Slack </dev/null &>/dev/null & # start slack process in detached mode
fi
Expand Down

0 comments on commit ef93654

Please sign in to comment.