5

I'd like to run chrome-based browser with a dark-mode on.

I can do it by

  1. going to: chrome://flags
  2. finding #enable-force-dark flag
  3. setting it "Enabled"

It works on my Linux system both on Chromium and Vivaldi, but it's a cumbersome approach when you need to toggle between dark/light mode everyday.

So is there any easier/faster way of setting specific flag? The best option would be to create a shortcut button for this action, but is it possible and how to do it?

As a substitute I wanted to run a browser from a command line with a specific flag set to "enabled" but it doesn't work. I found here that there is a "force-dark-mode" flag and according to this page, I tried to run

chromium --force-dark-mode 

and

chromium --force-dark-mode=enabled

In chromium it has no effect on the content of the page, it just changes the colour of the window frame. In vivaldi it has no effect at all. I also tried

chromium --enable-force-dark

Again, it has no effect at all neither in Chromium nor in Vivaldi. What's wrong with my approach?

2 Answers2

4

OK. Finally, I found the answer that works for me. Here it is said that the correct command that allows running browser with dark mode on is:

chromium --enable-features=WebContentsForceDark

I still don't know how to toggle it with the use of a button.

EDIT: I've just found that source code for dark reader extension for chrome is published on github. I compiled the source code locally and got it working. This clears up all my doubts and fears concerning the privacy and security of the chromium extensions.

0

to use a dark theme for the chromium UI, set the environment variables GTK_THEME and XDG_DATA_DIRS

on the opposite, to force light mode for the chromium UI, unset the XDG_DATA_DIRS env

note: this is different (better) than "pick a theme color" in chrome://settings/manageProfile because with this, everything is dark, where chromium's "theme color" allows me to pick only one color, and there are still white areas in the UI

#! /usr/bin/env bash

chromium-darkmode.sh

#export GTK_THEME=Adwaita-dark export GTK_THEME=Breeze-Dark

note: XDG_DATA_DIRS can be multiple paths separated by ":"

export XDG_DATA_DIRS=/usr/share # debian/arch/... #export XDG_DATA_DIRS=/run/current-system/sw/share # nixos

gtkrc_path="$XDG_DATA_DIRS/themes/$GTK_THEME/gtk-2.0/gtkrc"

if ! [ -e "$gtkrc_path" ]; then echo "error: missing gtkrc file: $gtkrc_path" >&2 exit 1 fi

echo "ok: using gtkrc file: $gtkrc_path" >&2

exec chromium "$@"

example gtkrc file: Breeze-Dark/gtk-2.0/gtkrc (source: breeze-gtk)

alternative: set qt theme via QT_QPA_PLATFORMTHEME and/or QT_STYLE_OVERRIDE, and probably also XDG_DATA_DIRS, see also arch wiki: Qt

milahu
  • 297