The short answer is: You can't, without hacking slack.
The long answer is that exactly how to hack it will differ from one version to the next, as they update the source code. We should all team up and submit a feature request (or maybe this could even be considered a bug – it's clearly bugging people).
Until then, this should be a community wiki, to prevent a new answer from being generated for each new slack version. Add your scripts here, and clearly state the latest version on which it works, newest on top.
4.7.0
This is an improvement on Dmitry S.'s answer.
unreads>0
is replaced with false
, so slack should always think there are no unread messages.
- Replacement is done in all
.js
files, since the code seems to have been split up in the latest version.
asar
is not run with super user privileges, which is useful for people using npm-g_nosudo
.
Prerequisites:
asar
installed globally through npm: npm install -g asar
Script:
#!/usr/bin/env sh
set -eu
# Clean up previous failed attempts
rm -rf ~/tmp/slack
rm -rf ~/tmp/app.asar
# Unpack
mkdir -p ~/tmp/slack
asar extract /usr/lib/slack/resources/app.asar ~/tmp/slack
# Modify
sed -i 's/unreads>0/false/g' ~/tmp/slack/dist/*.js
# Replace
sudo rm /usr/lib/slack/resources/app.asar
sudo rm -rf /usr/lib/slack/resources/app.asar.unpacked
asar pack ~/tmp/slack ~/tmp/app.asar
sudo cp ~/tmp/app.asar /usr/lib/slack/resources/app.asar
sudo cp -r ~/tmp/slack /usr/lib/slack/resources/app.asar.unpacked
echo "Enjoy your productivity"