Useful snippets #5: GTK3 dark theme with Firefox

A long-standing problem with Firefox on Linux, when an user is using a dark GTK3 theme like Adwaita:dark, is the “bleeding” of the desktop colors to the actual web page. Because almost all web developers assume that everyone is using a light theme anyway, that “bleeding” can in some cases cause the web page to become unusable, and in any case it looks ugly.

There’s a widget.content.gtk-theme-override setting in about:config, which is supposed to fix the issue, but I’ve never managed to make it work on any Firefox version.

However, I noticed almost accidentally that, if firefox is started for example with a script

  1. #!/bin/bash
  2. GTK_THEME=
  3. firefox

then the “bleeding” does not happen. It seems that when the GTK3 theme-defining environment variable GTK_THEME is an empty string, Firefox get confused and defaults to the light theme on web pages, but the UI still respects the gtk-application-prefer-dark-theme = 1 setting in ~/.config/gtk-3.0/settings.ini.

This entry was posted in Linux and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *