How can I enable dark mode in Chrome?
Short answer
cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications/google-chrome.desktop
sed -i 's;/usr/bin/google-chrome-stable;/usr/bin/google-chrome-stable --enable-features=WebUIDarkMode --force-dark-mode;g' ~/.local/share/applications/google-chrome.desktop
Please close all Google Chrome windows to apply changes.
Explained answer
A definitive solution would be to edit Chrome's desktop entry file so that every time you launch Chrome using the applications menu, it will run in dark mode.
A desktop entry file describes how a particular program is to be launched, and they have the .desktop
extension.
Desktop files managed by your package manager are located in /usr/share/applications
(they will be recreated every time the corresponding package updates) and desktop files managed by your user are located in ~/.local/share/applications
— this is where you should create personal desktop entries, and desktop files here override the package manager ones.
You need to create a personal desktop entry for Chrome, so you can edit it and make changes permanent for your user. That means you have to copy the original file to your desktop entries directory.
cp /usr/share/applications/google-chrome.desktop ~/.local/share/applications/google-chrome.desktop
Now you need to modify the Exec key inside Chrome's desktop entry file to change the command that runs this program. The new command will start Chrome on dark mode.
You need to open ~/.local/share/applications/google-chrome.desktop
on a text editor and where you find something like Exec=/usr/bin/google-chrome-stable %U
change it to Exec=/usr/bin/google-chrome-stable --enable-features=WebUIDarkMode --force-dark-mode %U
.
You can use sed
to do this automatically:
sed -i 's;/usr/bin/google-chrome-stable;/usr/bin/google-chrome-stable --enable-features=WebUIDarkMode --force-dark-mode;g' /usr/share/applications/google-chrome.desktop
Done. Please close all Google Chrome windows to apply changes.
See the Desktop Entry Specification for more details.
Related videos on Youtube
DODE
Updated on September 18, 2022Comments
-
DODE over 1 year
I'm running ubuntu 19.10 and I tried to enable dark mode by running
google-chrome-stable --enable-features=WebUIDarkMode --force-dark-mode
in terminal then it works but gives me this and chrome would close then return to light mode when i relaunchERROR:child_process_sandbox_support_impl_linux.cc(79)] FontService unique font name matching request did not receive a response.
what can i do to keep chrome in dark mode and close the terminal without closing chrome
-
dsSTORM over 4 yearstry
google-chrome-stable --enable-features=WebUIDarkMode --force-dark-mode &
-
Terrance over 4 yearsI am experiencing the same thing when I run Chrome from a terminal window. It is not affecting the way that Chrome is working and this appears to be generated by the Allow Google to run in the Background icon you see on the taskbar.
-
DODE over 4 years@dsSTORM chrome still closes when i close the terminal and changes to light again
-
DODE over 4 years@Terrance i tried disabling it from the settings but nothing changes
-
DK Bose over 4 years@Terrance, I pasted OP's code into gnome-terminal in Ubuntu 19.10 and google-chrome opened in dark mode. Adding
& exit
to the code allows me to launch google-chrome from the terminal and to automatically exit the terminal. I can do this repeatedly and always have the browser open in dark mode. Of course, my preferred route is to bindgoogle-chrome-stable --enable-features=WebUIDarkMode --force-dark-mode
to a keyboard shortcut for convenience. So I don't understand OP's question. Could you please clarify your experience? -
Terrance over 4 years@DKBose I am only seeing the error message while I keep the terminal open, but I am not getting kicked out of my Chrome and it reopens. This to me sounds like it needs to have a bug report opened on it.
-
DK Bose over 4 years@Terrance one bug related to FontService.
-
Terrance over 4 years@DODE The command that DKBose runs with the
& exit
at the end of it should work fine and keep google chrome open. As far as the error messages go DKBose also did link a bug to the error. -
DODE over 4 years@DKBose the command works fine thank you
-
DODE over 4 years@Terrance okay i will check it out thank you
-
Thomas Guyot-Sionnest over 2 yearsThe
--enable-features=WebUIDarkMode
is no longer required (at least when using the GTK+ theme) but there is still an open issue preventing Chrome from using the OS theme preferences for web pages: bugs.chromium.org/p/chromium/issues/detail?id=998903
-
-
hashlash over 2 yearsI had to restart for this to work
-
Thomas Guyot-Sionnest over 2 yearsIf you edit
/usr/share/applications/google-chrome.desktop
it will get reverted on the next chrome update. You should copy it to~/.local/share/applications/google-chrome.desktop
and override it locally. Also note the--enable-features=WebUIDarkMode
is no longer required (at least when using the GTK+ theme) but there is still an open issue preventing Chrome from using the OS theme preferences for web pages: bugs.chromium.org/p/chromium/issues/detail?id=998903