Skip to content

Use the color-scheme XDG portal on Linux for checking if the theme should be light/dark #643

@X-m7

Description

@X-m7

Currently as I understand it TAO checks the current GTK theme to see if it contains "dark" in the name, however now there is a way to ask the desktop environment using XDG portals and D-Bus. The protocol was added here, and GNOME has provided documentation on how to use it here (specifically see the "Other" section, which has example code written using C, SDL and GDBus/GIO, while the other sections assume libadwaita or libhandy is used).

The advantage of this method is that starting in GNOME 42 and elementaryOS 6 there is a global light/dark theme selector in their settings apps, which does not change the selected GTK theme, so only apps that check the portal setting will be able to follow that global light/dark preference. KDE Plasma also has such a light/dark setting, although ultimately the reported value from the portal is calculated using the selected colour scheme.

Also, using the portal to check the light/dark preference also means that apps will be able to respond immediately to the user switching between light and dark modes, while with the current method changing the GTK theme requires a restart of the apps.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    📬Proposal

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions