Proper fix for using device dark mode in Chrome

This commit is contained in:
David Heinemeier Hansson
2026-04-24 10:39:40 +02:00
parent 0be4648773
commit 1d4c859c71
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -24,4 +24,4 @@ sudo mkdir -p /etc/brave/policies/managed
sudo chmod a+rw /etc/brave/policies/managed
# Default Chromium to follow system appearance ("device") instead of dark
echo '{"browser":{"theme":{"color_scheme":0}}}' | sudo tee /usr/lib/chromium/initial_preferences >/dev/null
echo '{"browser":{"theme":{"color_scheme":0,"color_scheme2":0}}}' | sudo tee /usr/lib/chromium/initial_preferences >/dev/null
+9
View File
@@ -0,0 +1,9 @@
echo "Fix Chromium appearance mode to also set color_scheme2 (the field Chromium actually reads now)"
echo '{"browser":{"theme":{"color_scheme":0,"color_scheme2":0}}}' | sudo tee /usr/lib/chromium/initial_preferences >/dev/null
# Update existing Chromium profiles so color_scheme2 follows the system, not dark
PREFS="$HOME/.config/chromium/Default/Preferences"
if [[ -f "$PREFS" ]] && command -v jq &>/dev/null; then
jq '.browser.theme.color_scheme = 0 | .browser.theme.color_scheme2 = 0' "$PREFS" > "$PREFS.tmp" && mv "$PREFS.tmp" "$PREFS"
fi