RFC: Protocol for reading global (style) settings or properties
Platforms such as macOS and Windows provide functions for accessing global settings such as "double click time" (see here Win32/macOS) or the current "accent colour" (again, see here Win32/macOS).
Functions like these enable developers to create applications, that look or at least feel consistent on the platform. As far as I am aware, there is no proper alternative except for libraries such as Gio
, which are not necessarily authoritative and are bound to a distinct toolkit and/or WM/compositor.
The need for such interface is, IMHO, evident given "recent" issues, that I came across such as #57 or xdg/xdg-specs#95 (comment 1493449).
The aspect that strikes me the most is that this can bring some consistency for applications using CSD by requesting things such as "accent colour", "border width" without being coupled to a toolkit the compositor may or may not use.
Request for comment
Given that there is no protocol for this yet, would you even accept such interface? (I can't be the first one to think of such protocol). To be clear, I am envisioning an API similar to GIO, where a developer can try to request properties using keys. I.e. like that (warning, ignoring conventions for the examples sake):
bool has_xyz = wl_store_has(u8"property-xyz");
type = wl_store_get_type(u8"xdg:accent-color");
u16 border_width = 0;
wl_store_get_u16(u8"xdg:border-width", &border_width);
u32 accent_color = 0;
result = wl_store_get_u32(u8"xdg:accent-color", &accent_color);
bool is_dark_mode = false;
wl_store_get_boolean(u8"xdg:dark-mode-enabled", &is_dark_mode);
path font_path = null_path;
wl_store_get_path(u8"xdg:decoration-title-font-path", &font_path);
// A result type may be used to check, whether the property exists at all
// and if the property is assignable to the given variable.
// Alternatively, getters may return an "any" type and it is the developers
// responsibility to determine the type.
// ...
// Analogous for other, primitive types.
//
//
// After an incubation period, one could make vague attempts at standardizing certain properties
// and provide constants:
//
u32 accent_color = 0;
result = wl_store_get_u16(WL_STORE_XDG_ACCENT_COLOR, &accent_color);
Keys should be strings following a strict schema, perhaps even reverse domain notation to prevent conflicts.
Properties may be enumerated following a similar scheme as seen in wl_registry_listener
.
Considering XOrg, one can probably implement this there as well by using prefixed atoms, e.g. "PROP:org.freedesktop.dark-mode-enabled".
I'd like to develop a protocol like this, but:
- What are your thoughts on that?
- Are you willing to accept such protocol at all?
- Is there something that needs special thought?