56

I have a dark GTK theme installed in my Ubuntu 10.10 install and a persona installed for Firefox that I also like.

The problem is that Firefox is using my dark GTK theme for items like buttons and text fields on common web pages, and this commonly creates unreadable menus, text areas, and buttons. (white text on white backgrounds, or black text on black buttons).

I don't want to change either theme, because they look great in every other application, and I don't want to have to do something crazy to my Firefox install like use custom user scripts or CSS overrides.

All I want to do is tell Firefox to stop using my GTK theme completely. This appears to be what Google's Chrome browser does and it makes the most sense by far.

How can web developers possibly work around all the possible GTK themes out there?

0

13 Answers 13

52

Permanent solution:

You can specify a light GTK theme to use for rendering webpages in about:config. This is great because your system theme will still apply for menus etc. but the webpages will be rendered as they are with light themes.

  1. Navigate to about:config in your Firefox browser
  2. Right click and select new->string
  3. Enter widget.content.gtk-theme-override as the name
  4. Enter a light GTK theme that you have installed on your system for the value. e.g. Arc
  5. Restart firefox.

Source: https://www.reddit.com/r/firefox/comments/6rbvvw/photon_rectangular_tabs_have_landed_in_nightly/dl4318f/

See also https://bugzilla.mozilla.org/show_bug.cgi?id=1283086

3
  • 2
    I love this and it works. Save the setting in Firefox itself, not somewhere obscure in the system or a desktop entry :)
    – jocull
    Nov 6, 2018 at 18:43
  • And it's not needed to restart Firefox. It is applied instantly. Feb 15, 2019 at 14:20
  • A year later (2020), and we are now on firefox 82. I am glad to say that this still works. Sorry for my initial comment. I set widget.content.gtk-theme-override to High Contrast theme and I have never been happier. Firefox now looks beautiful. The theme only affected input fields, so all of them look very good and I am loving it. I'm now running arch, so in order to get the High Contrast theme, I had to install this package. I'm not sure what to install on Ubuntu, but just wanted to let you guys know what worked
    – smac89
    Sep 6, 2020 at 15:58
37

Start Firefox with one of the following command:

  • GTK3 Firefox 46+: env GTK_THEME=Adwaita:light firefox
  • GTK2 Firefox <46: env GTK2_RC_FILES=/usr/share/themes/Simple/gtk-2.0/gtkrc firefox

This will launch Firefox using the Simple/Adwaita:light theme, which is pretty basic and should blend with your Persona. You can try other themes, by replacing Simple with the theme name, but this doesn't work with all themes.

So far I have successfully tested with Simple and Redmond themes...

Before

Before

After

After

3
  • 4
    This no longer works with Firefox 46 because of the switch to GTK 3. May 1, 2016 at 13:47
  • It's worth noting that theme names are case sensitive, so adwaita is not the same as Adwaita. I was running into problems because unity-tweak-tool doesn't list the exact theme names, but alters capitalization in some cases. Jul 18, 2017 at 11:25
  • Thanks to Arch Wiki, we have a new workaround from this.
    – mja
    Apr 4, 2018 at 13:08
11

UPDATE: My original answer actually gets overwritten when Firefox updates.


My current (permanent) solution

Edit
~/.mozilla/firefox/abcdef.default/chrome/userContent.css
(where abcdef is a random string)

Add

input:not(.urlbar-input):not(.textbox-input):not(.form-control):not([type='checkbox']):not([type='radio']), textarea, select {
    -moz-appearance: none !important;
    background-color: #eee;
    color: #111;
}

Original answer

I found a solution to make Firefox completely ignore your GTK theme.

Edit /usr/share/applications/firefox.desktop and change

Exec=firefox %u

to

Exec=bash -c 'GTK_THEME=" " firefox %u'

When you (re)start FF it will only use the FF theme.

1
  • I consider this to be the best answer. Here is why: I have dark mode set for all my apps (apt, flatpak, snap). Life was good. Firefox updated in 2021. "You want dark mode? Here you go!" Web designers I trust: "Normalization: Overwrite every style on your page at least once." Sites which ignored this advice: dark text in dark input boxes! I tried widget.content.gtk-theme-override which did not work, providing environment variables does work, but when I tried this on Ubuntu 18.04 it did not work reliably for dash or pins. Editing userContent.css again. Yay. :-)
    – LiveWireBT
    Mar 7, 2021 at 21:08
9

I would like to add to the great answer of @lovinglinux a way to make Firefox to load the theme when opened from a launcher in the taskbar instead of command line:

  1. Copy the Firefox desktop file to your home directory.

    mkdir -p "/home/$USER/.local/share/applications/"
    cp -v "/usr/share/applications/firefox.desktop" \
      "/home/$USER/.local/share/applications/"
    
  2. In the Exec line, replace the value after = with a command using the instructions provided by the mentioned @lovinglinux:

    bash -c 'GTK2_RC_FILES=/usr/share/themes/Redmond/gtk-2.0/gtkrc firefox %u'
    

Kate editing firefox.desktop

And the result is this:

Firefox with Redmond theme and all other applications with a dark theme

4
  • 1
    Thank you for showing how to modify the .desktop file. That makes it very convenient! I'm using your solution for LibreOffice.
    – user25656
    Dec 30, 2013 at 7:11
  • The desktop file gets overwritten each time that Firefox updates so this is not a permanent solution
    – rviertel
    Sep 9, 2018 at 16:09
  • User rviertel is right. You should not edit files maintained by the package manager for everyone on the system. You will either receive updates which override your modifications which you may have forgotten about, or things will at some point not work correctly for everyone.
    – LiveWireBT
    Mar 7, 2021 at 21:12
  • I tried to make the least invasive edit, but someone should take a second look at this when using this answer. spwaning an extra bash subshell may introduce more problems.
    – LiveWireBT
    Mar 7, 2021 at 21:23
2

The best solution to tell Firefox that it should use the light theme instead of the dark is by specifying the GTK_THEME variable prior to launching.

So, 4 ways you get for doing this..

1- from terminal you can do:

GTK_THEME=Adwaita:light firefox

2- if you hate the terminal and wanna close it once firefox works:

GTK_THEME=Adwaita:light firefox &

3- from firefox about:config you can set the following setting to false:

browser.display.use_system_colors

WON'T WORK FOR localhost SITES! so if you are a web developer/designer it won't work out that well for you.

4- if you want this to be the defualt behavior:

Just add two lines to the Firefox launcher script located at /usr/lib/firefox/firefox.sh

in the terminal type down:

sudo gedit /usr/lib/firefox/firefox.sh

look at the beginning of the script for this:

MOZ_LIBDIR=/usr/lib/firefox
MOZ_APP_LAUNCHER=`which $0`
MOZ_APP_NAME=firefox

export MOZ_APP_LAUNCHER

and change it to this:

MOZ_LIBDIR=/usr/lib/firefox
MOZ_APP_LAUNCHER=`which $0`
MOZ_APP_NAME=firefox
GTK_THEME=Adwaita:light

export MOZ_APP_LAUNCHER
export GTK_THEME

Finally, restart Firefox.

Hope this helps.

Please help me by voting this up.

Thank you :)

1
  • This worked for me. Thank you! +1
    – VenoM
    Jun 1, 2018 at 3:32
2

This add-on (suggested by koushik) works well for me.

I'm using Firefox 57 on Ubuntu MATE 17.10

1
  • Thanks, this extension worked perfectly for Firefox Quantum on Fedora.:)
    – john400
    Aug 29, 2018 at 4:35
2

There is a very simple way to get the default color scheme back for web pages while still keeping your GTK theme for Firefox elements. I know it's not exactly what was asked, but it may help people coming here from a Google search.

  1. Navigate to about:config in your address bar.
  2. Scroll down until you see the settings
    • browser.display.foreground_color
    • browser.diaplay.background_color
  3. If those settings have been modified, right-click them and select reset.

That should be it, no restart necessary. This works with Firefox Quantum.

Settings in about:config

2

I'm using the Adwaita dark theme with Ubuntu 18. I'm using the default theme in firefox 63.0. The best solution in my case, with no side effects at all, was to force firefox to use a light theme (Adwaita in my case) for web content rendering only :

  • Open about:config in the address bar.
  • Create a new string entry : widget.content.gtk-theme-override ( right click > New > String ).
  • Set the value to the light theme to use for content rendering (Adwaita in my case ).
  • Restart firefox.

Change the GTK theme for content process only

1

You could start Firefox with a different user and the same profile. Copy your current profile (~/.mozilla/firefox/profile) to that different user's folder, chown it to the user, and then on your console run:

su newuser
firefox -profilemanager

This sounds a bit overkill, but you can put it into a script. Firefox will use the theme on the profile, but keep the unthemed GTK from the new user.

Also, this is the kind of stuff that makes it fun to use Firefox and Ubuntu :P

0

You can add another theme to Firefox that you like from Tools -> Addons -> Themes. Then just use that theme instead of the default one.

2
  • 2
    You can't use a different Firefox theme while using Personas Oct 19, 2010 at 20:01
  • 1
    Oh wow, thanks. Did not realize. (Also glad you are here, Firefox users should be helped a great deal! :)) Oct 19, 2010 at 20:04
0

Bannaz solution works great since I don't use .desktop files, but sometimes (or maybe every time) when I upgrade Firefox, my patch to the launcher script disappear.

So my solution to this is to create a new launcher script file which sets the preferred GTK theme, executes the original launcher script and does not get affected by an upgrade.


The original launcher on my system is located at /usr/bin/firefox.

I created a new launcher located at /usr/bin/local/firefox containing the following:

#!/bin/sh
export GTK_THEME=Adwaita
exec /usr/bin/firefox "$@"

Change the path locations to suit your system. And don't forget to make it executable:

sudo chmod +x /usr/local/bin/firefox
0

Personally, I like to use a dark theme for Firefox but I do not want a dark theme for websites. Recently, Google and other websites like archwiki started using prefers-color-scheme in their css to automatically switch to your browser's dark or light theme.

On Firefox version 95, all I had to do was go to about:config and change the value of layout.css.prefers-color-scheme.content-override to 1.

After making the change, restart your browser and be sure to clear your cookies.

It should be noted that this applies to Google search and other pages when the user is not signed in. You may also have to adjust your individual user settings for websites like Twitter, Facebook, and Google that also use an independent dark setting for each user as these settings are independent of your GTK and/or browser theme.

0

I came to this question wondering the same thing, after getting tired of bugs with Firefox's GTK implementation, however since none of the answers right now truly get rid of GTK integration, I decided to try removing as much of Firefox's GTK integration as possible myself.

The end result is https://github.com/dominichayesferen/Firefox-CSSTheme-GTKless. It isn't a full removal of GTK theme usage, due to userChrome limitations, but it covers most of what can be changed with userChrome.

You could very likely fully remove GTK theme usage with source code modding, but I unfortunately would not know how to.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .