5

I'm using Fedora 36, which has default Gnome desktop environment. I have dark theme turned on in Gnome settings -> Appearance (NOT gnome tweaks). When I open firefox, it automatically detects my system dark, and when I go to google search in firefox, it properly appears as dark. I'm not even logged in.

However, when I use Google chrome, it does not properly detect system theme. It still appears white when I go to google search. Anything I have to manually do to get Google chrome working as well as firefox here?

EDIT same exact thing happens in Debian 11. Firefox works perfectly for auto-detecting device theme for dark mode; Chrome does not.

5 Answers 5

3

I think it's not implemented yet to work with new Gnome API. You can use temporarily workaround, i wrote shell script file (run with sudo):

sed -i 's/^Exec=\/usr\/bin\/google-chrome-stable$/& --enable-features=WebUIDarkMode --force-dark-mode/' /usr/share/applications/google-chrome.desktop
sed -i 's/%U/--enable-features=WebUIDarkMode --force-dark-mode &/' /usr/share/applications/google-chrome.desktop

Edit for Chromium users:

sed -i 's/^Exec=\/usr\/bin\/google-chrome-stable$/& --enable-features=WebUIDarkMode --force-dark-mode/' /usr/share/applications/chromium-browser.desktop
sed -i 's/%U/--enable-features=WebUIDarkMode --force-dark-mode &/' /usr/share/applications/chromium-browser.desktop
1
  • If you don't have sudo rights or don't want to change files belonging to an RPM package you can simply create a drop-in in your $HOME: sed 's/%U/--enable-features=WebUIDarkMode --force-dark-mode &/' /usr/share/applications/chromium-browser.desktop > ~/.local/share/applications/chromium-browser.desktop That way the work-around is also stable over chromium/chrome package updates. Feb 5, 2023 at 17:18
1

apparently this is a known bug in Chromium.

Issue 998903: Dark Gtk theme does not affect prefers-color-scheme media query Still matches 'light' even if the UI instance for NativeThemeGtk renders a dark UI.

1

For a workaround add to ~/.config/chrome-flags.conf

--enable-features=WebUIDarkMode,CSSColorSchemeUARendering
--force-dark-mode

This will force dark mode only for chrome's setting pages.

1
  • 2
    The Arch wiki describes this config file for Chrome and analogously ~/.config/chromium-flags.conf for Chromium. However, the Fedora 37 chromium doesn't try to read any *flags.conf (I've straced it). Perhaps this is an Arch-only feature? Feb 19, 2023 at 22:52
0

On Fedora you can open: chrome://flags/#enable-force-dark and enable that Auto Dark Mode for Web Contents option. Then on chrome://settings/appearance ensure GTK+ option is active. Maybe it works for other distributions Gnome 42, I'm gonna appreciate your comments.

2
  • This doesn't change the evaluation of prefers-color-scheme CSS media feature expressions. I.e., as of 2023-02/Fedora 37, Chromium evaluates @media (prefers-color-scheme: light) { ...} as matching by default and still after enabling the 'Auto Dark Mode'. This mode indeed changes the background to dark and uses a light font color - but it works more like the Dark-Reader addon, i.e. it comes up with some dark scheme on its own instead of relying on the sites CSS supporting dark mode via CSS media selectors. Feb 5, 2023 at 17:29
  • I appreciate your comment. Until there's no "official" solution I'll need to keep on some workarounds. Feb 9, 2023 at 16:34
0

If you want to automatically use the dark/light mode based on your gnome theme settings, then you can run the following.

google-chrome-stable $(echo $(gsettings get org.gnome.desktop.interface color-scheme) $(gsettings get org.gnome.desktop.interface gtk-theme) | grep -vq dark || echo --enable-features=WebUIDarkMode --force-dark-mode)

or if you're using chromium . . .

chromium $(echo $(gsettings get org.gnome.desktop.interface color-scheme) $(gsettings get org.gnome.desktop.interface gtk-theme) | grep -vq dark || echo --enable-features=WebUIDarkMode --force-dark-mode)

You must log in to answer this question.

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