True Dark Mode for Chrome browser on Linux

Problem

Regardless of your desktop environment (Gnome, KDE, ...), and even if you set your global theme as a dark theme, you may have seen that Chrome was not following this setting. It does not know if your computer uses dark mode as it would know on Windows. You could set a theme for Chrome, but the browser core would continue using a white mode (check the settings page for example)

Solution

There is a quick fix for that, and it is a simple bash command:

echo "--enable-features=WebUIDarkMode\n--force-dark-mode" >> ~/.config/{chrome,chromium}-flags.conf

Open the settings page, Chome now uses dark mode!

Before :

After:

Explanations

Chromium browsers read the file "~/.config/chromium-flags.conf" when exists.

Thanks to the following command, we add the following lines to the file.

echo "--enable-features=WebUIDarkMode\n--force-dark-mode" >> ~/.config/{chrome,chromium}-flags.conf
--enable-features=WebUIDarkMode
--force-dark-mode

These settings force Chrome to use a dark mode UI instead of the default it knows. And, on Linux, the default UI mode Chrome knows is the light mode because the desktop environments work differently from the Windows desktop environment.

On Windows, the browser can detect if you are using light or dark mode. On Linux, it can't.