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=205Is there any possible way to enable it using command line switches?
Force Dark Mode for Web Contents flag
2 Answers
This was answered in Google Groups:
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: defined here:
You can specify the params for each group via command line using --force-fieldtrial-params:
And then you can force yourself into a particular group via command line using --force-fieldtrials:
You'll have to play around with the syntax (it's pretty tricky/annoying), but that should get you started.
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:
- Enabled:
--enable-features=WebContentsForceDark
- Enabled with simple HSL-based inversion:
--enable-features=WebContentsForceDark:inversion_method/hsl_based/image_behavior/none/text_lightness_threshold/256/background_lightness_threshold/0
- Enabled with simple CIELAB-based inversion:
--enable-features=WebContentsForceDark:inversion_method/cielab_based/image_behavior/none/text_lightness_threshold/256/background_lightness_threshold/0
- Enabled with simple RGB-based inversion:
--enable-features=WebContentsForceDark:inversion_method/rgb_based/image_behavior/none/text_lightness_threshold/256/background_lightness_threshold/0
- Enabled with selective image inversion:
--enable-features=WebContentsForceDark:inversion_method/cielab_based/image_behavior/selective/text_lightness_threshold/256/background_lightness_threshold/0
- 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
- Enabled with selective inversion of everything:
--enable-features=WebContentsForceDark:inversion_method/cielab_based/image_behavior/selective/text_lightness_threshold/150/background_lightness_threshold/205
- Disabled:
--disable-features=WebContentsForceDarkThis 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.