Repository navigation
Linux: follow the desktop's light or dark preference through the XDG portal - #40
Merged
Merged
Conversation
…portal winit reports no theme on Wayland unless the app set one, so every Rune window and overlay on Linux drew dark whatever the desktop preferred. When winit has nothing, read org.freedesktop.appearance color-scheme from the settings portal and follow SettingChanged; a change redraws each window, which rereads it. No preference, no portal or no session bus keep dark. Co-Authored-By: Claude Opus 5.5 <[email protected]>
thdxr
added a commit
to anomalyco/hokum
that referenced
this pull request
Oct 29, 2026
Bump Rune to c1fd012, which reads the XDG portal's color-scheme when winit reports no theme (anomalyco/rune#40 by @salemsayed), and adapt the tray to Rune's TraySpec/TrayIcon constructors. Fixes #20
thdxr
added a commit
to anomalyco/hokum
that referenced
this pull request
Oct 29, 2026
…21) Bump Rune to c1fd012, which reads the XDG portal's color-scheme when winit reports no theme (anomalyco/rune#40 by @salemsayed), and adapt the tray to Rune's TraySpec/TrayIcon constructors. Fixes #20
Member
|
Thanks a lot for this, really clean fix and a great writeup. Merged into dev as c1fd012, and Hokum now pins it (anomalyco/hokum#21). — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
thdxr
added a commit
to uncomplexity/hokum
that referenced
this pull request
Oct 29, 2026
…nomalyco#20) Bump Rune to c1fd012, which reads the XDG portal's color-scheme when winit reports no theme (anomalyco/rune#40 by @salemsayed). Ported from anomalyco#21. Fixes anomalyco#20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Linux, winit reports no theme unless the app set one, and layer surfaces have no winit window at all, so
window.theme().is_none_or(..)makes every Rune window and overlay draw dark whatever the desktop prefers. Hokum shows it: on Hyprland with a light desktop, its notification cards are light (Hokum reads the portal itself inbus.rs), but the settings window and its preview are dark with Appearance set to System.What changes
portal_appearance.rs(Linux only): a worker thread on a current-thread tokio runtime, like the file-dialog and shortcut portals, readsorg.freedesktop.appearancecolor-schemefromorg.freedesktop.portal.Settings(ReadOne, falling back toReadfor older portals) and followsSettingChanged. A change asks every window that registered to redraw, as a new accent does on macOS.preferences::window_darkresolves a new window's appearance:--theme, then winit's theme, then the portal, then dark.preferences::desktop_darkis the portal's answer for a window winit gives no theme;RedrawRequestedrereads it next to the accent.show_fading), and in their winit-window path.What stays the same:
color-scheme0 (no preference), no portal or no session bus keep dark.--themeand winit's own theme andThemeChangedstill win. On macOS, Windows and the web,preferences::dark()isNone, so nothing there changes.House rules:
window.rsis 4 lines shorter than before (moving the theme match intopreferencesmade room), and its ceiling infile-size-exceptions.txtis lowered to match.overlay.rsstays at its ceiling. The tests are in a siblingportal_appearance_tests.rs, and there is a changelog entry.Testing
On Arch with Hyprland and xdg-desktop-portal-gtk:
gsettings set org.gnome.desktop.interface color-scheme prefer-darkturns them dark within a second, with no focus change or click, andprefer-lightturns them back. Its notification cards still work.cargo test -p rune --lib portal_appearance: 2 new tests pass.cargo test -p rune --lib: 1105 pass and 5 fail, the same 5 that fail ondevwithout this change on this machine (edit::tests::hidden_multiline_pristine_replace_and_delete,keycaps::tests::repeated_chords_count_and_named_keys_use_glyphs,runtime::on_key_tests::a_truncation_tooltip_shows_only_while_the_text_is_cut, and two invideo::tests). Running the lib tests on Linux also needs theset_native_helptest fixed, as Linux: build the native-help test; test presses in a scrolled viewport #32 does; I did that locally for the run, and it isn't part of this PR.cargo check -p rune --lib --target wasm32-unknown-unknown: the new code compiles. The only errors are the existingweb_time::Instantmismatches nearcursor.reassert_at.Noneand no-op that compiles for wasm.🤖 Generated with Claude Code