Skip to content

feat(linux): rune::desktop_setting follows any XDG Settings portal key with change signals - #2193

Merged
opencodejr[bot] merged 1 commit into
devfrom
bot/issue-527
Nov 25, 2026
Merged

opencodejr[bot] merged 1 commit into
devfrom
bot/issue-527

Conversation

@opencodejr

@opencodejr opencodejr Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Adds rune::desktop_setting(namespace, key, on_change) -> DesktopSettingWatch and rune::DesktopSetting (Bool, Int, Uint, Double, Str, with as_bool, as_i64, as_f64 and as_str). Apps can follow any key of the XDG Settings portal, for example org.gnome.desktop.interface text-scaling-factor, cursor-blink or cursor-blink-time (#527).

Not compiled or tested. There was no Rust toolchain (cargo, rustc, rustup) where this change was made, so the checks the review asked for have not been run. Before merging, please run:

  • cargo test -p rune --lib desktop_settings
  • cargo test -p rune --doc desktop_setting (the no_run example)
  • cargo clippy -p rune --lib
  • cargo check -p rune --no-default-features

Only scripts/file-size.sh ran: no errors, no new warnings.

How it works

  • Reads come from Rune's existing portal worker (portal_appearance.rs). Following a key puts it on a queue of keys to read. In its SettingChanged loop, the worker waits on both the signal stream and that queue, and reads each queued key with ReadOne/Read (with RPC_TIMEOUT) between signals. A read never lands after a newer signal. Keys followed before the portal connects are read once it does.
  • App callbacks run on their own rune-desktop-settings thread. It starts with the first desktop_setting call and owns every watch. Values reach it in order and each callback runs under catch_unwind(AssertUnwindSafe(..)). A callback that panics is dropped. The worker never runs app code, and it handles Rune's own color-scheme, reduced-motion, enable-animations and double-click keys before passing a value on.
  • Each callback gets only new values. It is not called twice in a row with the same value.
  • Dropping the #[must_use] DesktopSettingWatch removes the watch.
  • When it does nothing: on other platforms, without the dbus feature, or when no portal answers, on_change is never called.
  • Changelog: changelog/unreleased/2026-11-25-linux-portal-desktop-setting.md.

Tests

desktop_settings_tests.rs (not run yet):

  • A watch gets only its own namespace and key, without repeats.
  • A panicking callback is reported (offer returns false) instead of unwinding.
  • The value accessors.
  • decode for each scalar type, double-wrapped values, and an array (which gives None). This test only builds on Linux with dbus.

Not checked against a live portal. The fake portal from #527 under headless sway would do that.

Not in this PR

Rune does not apply text scaling or cursor blink to its own text; apps read those values through this API.

Closes #527

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.

Linux: read Settings portal keys beyond color-scheme, with change signals

0 participants