RFC: Wayland protocol for Prefer Dark Style
The Need for a FreeDesktop Dark Style Preference provides a good background and the motivation for bringing the equivalent of "Dark Mode" from other operating systems to the Linux desktop.
The conclusion from that article is that this should be implemented as a freedesktop.org standard and there is even an initial draft, although it looks like it hasn't progressed much lately.
Would it make sense to create a Wayland protocol for exposing the user's "dark mode" preference to Wayland clients?
Just to make it clear, this protocol doesn't yet exist. This RFC is mostly about finding out if it would even make sense for such a protocol to exist. This may be the wrong place in the stack or just a plain stupid way of solving this problem, but it may be worth discussing it anyway.
One of the main arguments for implementing this using a Wayland protocol is that the applications that would most benefit from this protocol are the graphical applications which most likely already speak the Wayland protocol (due to being Wayland clients). One of the main cons of using a Wayland protocol for this would be that it will not work for Xorg applications.
I don't know what an Xorg equivalent for this protocol would look like, but I would guess that it should be possible to implement something similar for Xorg if demand is there and someone is willing to put in the work. But it can also be argued that lack of interest for such a protocol in Xorg should not hold back progress for it in Wayland if it turns our that this protocol is actually a good idea. This is hardly the first Wayland protocol that does not have an Xorg equivalent.
That being said, it would be nice if someone came up with a solution that would work for Xorg too.
The compositors supporting this protocol will just need to expose the user preference stored in their current configuration backend (e.g.: GSettings for GNOME,
~/.config/sway/config for sway, etc) over this new protocol.
- environment variables e.g.:
XDG_PREFERS_COLOR_SCHEME=dark(cons: not possible to change the value at runtime for running applications)
- D-Bus (cons: requires client applications to have a dependency on D-Bus)
- GSettings (cons: not desktop environment agnostic)