5

I trying to enable dark mode for web content based on time of day.
However I can not enable it using command line switches.

Nothing of that works for me:

--dark --force-dark-mode --blink-settings=inversion_method=cielab_based,image_behavior=selective,text_lightness_threshold=150,background_lightness_threshold=205

Is there any possible way to enable it using command line switches?

Force Dark Mode for Web Contents flag

2 Answers 2

5

There is actually a way to set whatever option of the flag you want to use. So, for "Force Dark Mode for Web Contents" it goes like this:

  1. Enabled:
--enable-features=WebContentsForceDark
  1. Enabled with simple HSL-based inversion:
 --enable-features=WebContentsForceDark:inversion_method/hsl_based/image_behavior/none/text_lightness_threshold/256/background_lightness_threshold/0
  1. Enabled with simple CIELAB-based inversion:
 --enable-features=WebContentsForceDark:inversion_method/cielab_based/image_behavior/none/text_lightness_threshold/256/background_lightness_threshold/0
  1. Enabled with simple RGB-based inversion:
--enable-features=WebContentsForceDark:inversion_method/rgb_based/image_behavior/none/text_lightness_threshold/256/background_lightness_threshold/0
  1. Enabled with selective image inversion:
--enable-features=WebContentsForceDark:inversion_method/cielab_based/image_behavior/selective/text_lightness_threshold/256/background_lightness_threshold/0
  1. Enabled with selective inversion of non-image elements:
 --enable-features=WebContentsForceDark:inversion_method/cielab_based/image_behavior/none/text_lightness_threshold/150/background_lightness_threshold/205
  1. Enabled with selective inversion of everything:
 --enable-features=WebContentsForceDark:inversion_method/cielab_based/image_behavior/selective/text_lightness_threshold/150/background_lightness_threshold/205
  1. Disabled:
 --disable-features=WebContentsForceDark

This was tested on Chrome Stable: Version 89.0.4389.114 (Official Build) (64-bit) and on Chromium: Version 92.0.4480.0 (Developer Build) (64-bit)

After setting a flag, you can check it out if it is used by going to chrome://version/, in the "Command Line" field.

0

This was answered in Google Groups: https://groups.google.com/a/chromium.org/forum/#!topic/chromium-discuss/x5xrFgYiDuE
However looks like there is not way to specify exact flag value.

Lily Chen wrote:

Try --enable-features=WebContentsForceDark

The params for each of the modes are listed here: https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/about_flags.cc;l=431-465;drc=5ba77dad98cf94506cf3700f9e12fcdc65fadfb6 defined here: https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/common/features.cc;l=342-389;drc=7c57ca1441dba6c5113af561692e88e6c33a6ba8

You can specify the params for each group via command line using --force-fieldtrial-params: https://source.chromium.org/chromium/chromium/src/+/master:components/variations/variations_switches.cc;l=22-30;drc=c3ecfbb8149e2b8843bfaf0489e4cd4404c18adb

And then you can force yourself into a particular group via command line using --force-fieldtrials: https://source.chromium.org/chromium/chromium/src/+/master:base/base_switches.cc;l=33-41;drc=12cd16ac3a46001b853793828f67e9cd6ffc7606

You'll have to play around with the syntax (it's pretty tricky/annoying), but that should get you started.

You must log in to answer this question.

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