Open salim-b opened 6 days ago
Hi! Yeah, that makes sense. I think this dark theming matter has changed so many times that I dropped out of the loop long ago. Maybe this one will stick? I might not actively work on this, but a PR or a code sample to query the color-scheme would be welcome. There seems to many ways of accessing this setting — the one that adds the least amount of problematic dependencies (preferably zero) would be best.
Maybe this one will stick?
I think so since it's a desktop-environment-agnostic standard and all the relevant players seem to be on board.
I might not actively work on this, but a PR or a code sample to query the color-scheme would be welcome. There seems to many ways of accessing this setting — the one that adds the least amount of problematic dependencies (preferably zero) would be best.
The GNOME people put together a blog post with background and some wiki-style help which I linked above. It should answer most of the questions/uncertainties.
Some relevant quotes from the blog post:
The new preference is defined in the settings portal as the
org.freedesktop.appearance.color-scheme
key (...) Manually accessing the portal is a bit tedious, and so we wrap it into an easy to use API. (...) For GNOME the API is in libadwaita and libhandy, and is vaguely inspired by CSS.
IIUC, NFO Viewer does not use libadwaita, so
If it's not possible to use libadwaita or libhandy, use DBus to manually access the settings portal and fetch the preference. Do not use the gsettings key backing the settings portal implementation other than as a fallback if the portal isn't present: that key only exists on GNOME and is an implementation detail. Don't add any animation for the transition; the whole screen will be animated on the compositor side instead.
They then go on and provide a simple example in C.
I have zero experience with any of this (or GTK GUI development in general), so I can't help much with implementation. But a GitHub code search for org.freedesktop.appearance color-scheme language:python
gives some examples that look relevant. 🙂
The XDG Desktop Portal specification provides the
org.freedesktop.appearance.color-scheme
preference to indicate the system’s preferred color scheme. Respecting this would allow the Flatpak to automatically choose the proper theme variant (light or dark).Currently, I have to manually override the GTK theme variant like this to make the NFO Viewer Flatpak open in dark mode:
(I'm using GNOME, although the above should apply to all Linux desktop environments implementing the XDG Desktop Portal spec.)
More information