Somewhere in the ordeal of switching from Arch to Debian on lisbon, I’ve wound up with a newer version of a library somewhere in the guts of Gtk which now ignores the old dark-theme hack, and which makes starting most Gtk tools such as Evince, my usual PDF viewer, an eye-watering experience.
The old way (and the commonly-documented way) to do this was to add
gtk-application-prefer-dark-theme=1
to the [Settings]
section
in ~/.config/gtk-3.0/settings.ini
:
But this has now started producing a warning that looks like:
(evince:789847): Handy-WARNING **: 17:15:12.363: Using GtkSettings:gtk-application-prefer-dark-theme together with HdyStyleManager is unsupported. Please use HdyStyleManager:color-scheme instead.
This appears to be part of a shift in the way themes work. It turns out the “old” way of doing this simply hacks a setting inside Gtk that, by my reading, should be set by the application to request the theme be applied in dark mode. That’s awful — but it’s the way it worked.
Thankfully, the changes here are a step in a positive direction! Adrien Plazas’ introduction to libadwaita describes, at least in part, the high-level rationale, and reading through the development discussions leads me to believe that Gtk 4’s model here is a substantial improvement.
But … how do you fix it?
The Fix
This one perplexed me for a while,
but eventually I found GNOME/gsettings-desktop-schemas!51
(and some related merge requests into libhandy and libadwaita),
which indicates a schema change to org.gnome.desktop.interface
,
adding a key color-scheme
:
color-scheme
: Color scheme. The preferred color scheme for the user interface. Valid values are “default”, “prefer-dark”, “prefer-light”.
That’s exactly what I want to set.
To do so, I commented out the now-obsolete setting,
and used gsettings
to configure the new one.
sed -i -e '/^gtk-application-prefer-dark-theme/ { s/^/# /; }' ~/.config/gtk-3.0/settings.ini gsettings set org.gnome.desktop.interface color-scheme prefer-dark
Hooray!