Skip to content

Instantly share code, notes, and snippets.

@DrewML
Last active January 25, 2022 00:53
Show Gist options
  • Save DrewML/0acd2e389492e7d9d6be63386d75dd99 to your computer and use it in GitHub Desktop.
Save DrewML/0acd2e389492e7d9d6be63386d75dd99 to your computer and use it in GitHub Desktop.
Theming Slack for OSX

Theming Slack for OSX

So, you love Slack, but you hate applications with large white backgrounds? Why not use Dark Mode!

Unfortunately, Slack does not have a Dark Mode, although it's on their list of possibilities.

But, don't fret - there is a solution! Because the slack native desktop apps are just wrappers around a web app, we can inject our own CSS to customize the application to our liking.

How to (OSX Only)

Prerequisite Your custom CSS needs to be hosted somewhere accessible over HTTP. For a free option, you can use a Gist and use the link to the raw file.

  1. Open up Slack.app, and navigate to any message;
  2. In the message input field, enter /macgap.app.enabledevelopertools(), and press enter
  3. Right click any element in the app (except the team switcher on the left), and choose Inspect Element
  4. Open the Console tab
  5. Run the following snippet of JavaScript in your console, replacing the value of cssURI with the URI that points to your custom stylesheet.
// Using ajax rather than a dynamically injected <link>, to account for sites (like gist.github.com) that don't serve
// a content-type for CSS files
var cssURI = 'https://gist.githubusercontent.com/DrewML/f244d6015c9b690b1dc241669b69dde1/raw/3d6351b8767ee5fba1ac86cad9b8cc5cf2ff9fea/slack-theme.css';
$.get(cssURI).then(function(css) {
   $('<style />').text(css).appendTo('body')
});

Example Dark Theme

image

Writing your own theme

If you know the basics of CSS and browser developer tools, writing a theme should be a breeze. You can either use the Developer Tools exposed in the Slack application itself, or you can visit https://{myteamhere}.slack.com/messages and use the browser dev tools of your choosing.

The part that's a bummer

Because you're just injecting styles in the DOM, this means that your changes do not persist when you exit and re-open the application. However, the Developer Tools will remember the last code you executed, so it should be a few keystrokes to open the panel and re-run your injection script.

@bh2smith
Copy link

@danilodequeiroz worked immediately! Amazing!

@rocajuanma
Copy link

@danilodequeiroz thank you!

@XLPI
Copy link

XLPI commented Jan 2, 2019

/macgap.app.enabledevelopertools() is not a valid command. In Slack, all messages that start with the "/" character are interpreted as commands.

If you are trying to send a message and not run a command, try preceding the "/" with an empty space.

What can I do?

@garyray-k
Copy link

@XLPI
Just got the same. I did an update and... :(
Commenting to follow while I dig into it a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment