Skip to content

IJPL-54591: Use XDG Desktop Portal to sync light/dark mode on Linux #3100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iso2013
Copy link

@iso2013 iso2013 commented Jun 21, 2025

This uses the XDG Desktop Portal spec for system settings, now standardized by freedesktop: https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Settings.html#org-freedesktop-portal-settings-read Specifically, it uses the org.freedesktop.appearance color-scheme setting to detect whether the user's OS is set to prefer dark mode.

To do this, it uses the dbus-send and dbus-monitor commands, part of the dbus-bin package. I'm sure there are Java-DBus interop APIs that could do this more elegantly, but I figured it wasn't worth adding a new dependency for what ends up being a pretty simple check.

(I also do not typically work in Kotlin; please let me know if there are ways I can improve my formatting or execution here, and I will gladly do so.)

This uses the XDG Desktop Portal spec for system settings, now standardized by freedesktop:
https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Settings.html#org-freedesktop-portal-settings-read
Specifically, it uses the `org.freedesktop.appearance` `color-scheme` setting to detect whether
the user's OS is set to prefer dark mode.

To do this, it uses the `dbus-send` and `dbus-monitor` commands, part of the `dbus-bin` package.
I'm sure there are Java-DBus interop APIs that could do this more elegantly, but I figured it
wasn't worth adding a new dependency for what ends up being a pretty simple check.
@iso2013 iso2013 changed the title Use XDG Desktop Portal to sync light/dark mode on Linux IJPL-54591: Use XDG Desktop Portal to sync light/dark mode on Linux Jun 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant