Skip to content

Instantly share code, notes, and snippets.

@andy-s-clark
Last active March 25, 2019 21:37
Show Gist options
  • Save andy-s-clark/e0e74b6e6652343ef5147ba82cf8756a to your computer and use it in GitHub Desktop.
Save andy-s-clark/e0e74b6e6652343ef5147ba82cf8756a to your computer and use it in GitHub Desktop.
Enable night-mode for Slack, using the buildcom fork of slack-night-mode
#!/bin/bash
if [ -f '/usr/lib/slack/resources/app.asar.unpacked/src/static/ssb-interop.js' ]; then
target='/usr/lib/slack/resources/app.asar.unpacked/src/static/ssb-interop.js'
elif [ -f '/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js' ]; then
target='/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js'
fi
if [ "z${target}" = "z" ]; then
echo 'Unsupported platform or Slack is not installed'
exit 1
fi
if [ "$(pidof slack)" != "" ]; then
echo 'Please close Slack'
exit 2
fi
if [ $(grep -c 'slack-night-mode' $target) -eq 0 ]; then
sudo cp "${target}" "${target}.bak"
cat <<EOF| sudo tee -a $target > /dev/null
document.addEventListener('DOMContentLoaded', function() {
\$.ajax({
url: 'https://raw.githubusercontent.com/buildcom/slack-night-mode/master/css/raw/black.css',
success: function(css) {
\$("<style></style>").appendTo('head').html(css);
}
});
});
EOF
echo 'Set up complete'
else
echo 'Already set up'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment