How can one make Firefox ignore my GTK theme entirely?
Solution 1
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
After
Solution 2
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.
- Navigate to
about:config
in your Firefox browser - Right click and select new->string
- Enter
widget.content.gtk-theme-override
as the name - Enter a light GTK theme that you have installed on your system for the value. e.g.
Arc
- Restart firefox.
See also https://bugzilla.mozilla.org/show_bug.cgi?id=1283086
Solution 3
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.
Solution 4
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:
-
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/"
-
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'
And the result is this:
Solution 5
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.
- Navigate to
about:config
in your address bar. - Scroll down until you
see the settings
browser.display.foreground_color
browser.diaplay.background_color
- If those settings have been
modified, right-click them and select
reset
.
That should be it, no restart necessary. This works with Firefox Quantum.
Related videos on Youtube
tamale
mid 30's computer geek from illinois cloud sre at confluent.io die-hard ubuntu/linux/open-source fan
Updated on September 17, 2022Comments
-
tamale almost 2 years
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?
-
lovinglinux over 13 yearsYou can't use a different Firefox theme while using Personas
-
NightwishFan over 13 yearsOh wow, thanks. Did not realize. (Also glad you are here, Firefox users should be helped a great deal! :))
-
Admin over 10 yearsThank you for showing how to modify the .desktop file. That makes it very convenient! I'm using your solution for LibreOffice.
-
Konstantin Pereiaslov about 8 yearsThis no longer works with Firefox 46 because of the switch to GTK 3.
-
Cedric Reichenbach almost 7 yearsIt's worth noting that theme names are case sensitive, so
adwaita
is not the same asAdwaita
. I was running into problems because unity-tweak-tool doesn't list the exact theme names, but alters capitalization in some cases. -
mja about 6 yearsThanks to Arch Wiki, we have a new workaround from this.
-
VenoM about 6 yearsThis worked for me. Thank you! +1
-
john400 almost 6 yearsThanks, this extension worked perfectly for Firefox Quantum on Fedora.:)
-
rviertel almost 6 yearsThe desktop file gets overwritten each time that Firefox updates so this is not a permanent solution
-
jocull over 5 yearsI love this and it works. Save the setting in Firefox itself, not somewhere obscure in the system or a desktop entry :)
-
Masood Khaari over 5 yearsAnd it's not needed to restart Firefox. It is applied instantly.
-
smac89 almost 4 yearsA 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
toHigh 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 theHigh 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 -
Csabi Vidó over 3 yearsI 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. :-)
-
Csabi Vidó over 3 yearsUser 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.
-
Csabi Vidó over 3 yearsI 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.