Skip to content

System light/dark mode not detected correctly on DMS #285

Done

Description

@broady

I'm on CachyOS using niri and DankMaterialShell. system_dark returns true even when I'm on light mode.

I can reproduce this with Hex. It's always in Dark mode.

Claude's investigation and research is below.

What happens

On Linux, an app that follows the system can't draw light on a light GNOME-style desktop. The desktop portal answers org.freedesktop.appearance color-scheme with 0 (no preference), and Rune resolves 0 the same way it resolves no portal at all: Cx::system_dark() is true and the window draws dark. The app can't tell that the portal answered.

A light desktop usually answers 0, not 2. GNOME Settings > Appearance has two styles, Default and Dark. Default writes color-scheme 'default' (cc-background-panel.c, on_color_scheme_toggle_active_cb), and the portal reports that as 0. libadwaita draws app windows light at 0: an app's default scheme is PREFER_LIGHT, "Use light appearance unless the system prefers dark colors" (adw-style-manager.c, AdwColorScheme). So on stock GNOME every other app window is light, and a Rune window that follows the system is dark.

0 → dark is deliberate, and I'm not asking to flip it everywhere. #40 kept it ("color-scheme 0 (no preference), no portal or no session bus keep dark"). Hokum reads 0 as dark "like the rest of Hokum" (bus.rs#L615-L635). Hex's tray keeps its white mark at 0 (tray.rs#L108-L110). Those are good defaults for cards, HUDs and tray marks. The gap is an app window that wants to match the desktop's other windows: no Rune API tells it the desktop is in GNOME's Default style.

Where

At dev 79fed3b5:

Repro

  1. On GNOME, pick Default in Settings > Appearance (color-scheme 'default').
  2. Read the portal:
    gdbus call --session --dest org.freedesktop.portal.Desktop \
      --object-path /org/freedesktop/portal/desktop \
      --method org.freedesktop.portal.Settings.ReadOne org.freedesktop.appearance color-scheme
    
    It prints (<uint32 0>,).
  3. Open an app whose Auto theme is cx.system_dark(), such as examples/settings on Auto. It draws dark next to light GTK windows.

I saw steps 2 and 3 with my own app on niri with DankMaterialShell in light mode, which leaves color-scheme at 'default' as GNOME's Default does. Step 2's output above is verbatim. I have not run examples/settings itself.

Proposed fix (additive; no app's output changes)

Let an app see the desktop's answer before the dark fallback, for example:

/// The desktop's stated preference: Some(true) dark, Some(false) light, None when it
/// states none (portal `color-scheme` 0) or nothing answers. `system_dark` is unchanged.
pub fn desktop_dark(&self) -> Option<bool>

An app that wants GNOME's behaviour writes cx.desktop_dark().unwrap_or(false). Hokum, Hex and every existing app keep drawing what they draw today.

Notes:

  • Env is on the list of types apps build as literals, so this can't be a new Env field. Since Linux: follow the desktop's light or dark preference through the XDG portal #40, a window rereads the portal on each redraw. It could keep the Option beside system_dark there, and a Cx method could read it.
  • If you'd rather make it a choice than an accessor, an App builder method for what 0 means (default: dark, as now) does the same job.
  • Changing window_dark's default for windows only (0 → light; overlays keep dark) would also fix it. That's your call, since it changes what existing apps draw on GNOME.

Workaround

None inside Rune. An app can read the portal itself, as Hokum's follow_color_scheme does. A user can run gsettings set org.gnome.desktop.interface color-scheme prefer-light, which makes the portal answer 2 (per #40's testing). I didn't try that here, and it leaves neither style selected in GNOME Settings.

Environment

CachyOS (Arch), niri 26.04, DankMaterialShell in light mode with its portal sync on, xdg-desktop-portal 1.22.1 with the gnome (51.0) and gtk (1.15.3) backends, Rune 79fed3b5 (dev).

Happy to recheck on a dev rev with the change.

Done when: on a desktop whose portal answers color-scheme 0, an app can find out that the desktop stated no preference (and so draw light, as libadwaita does), while apps that don't ask draw exactly what they draw today.

Activity

  1. Hona commented on Nov 23, 2026

    @Hona
    Member

    Fixed on dev in #1743 (23edd141).

    In crates/rune/src/platform/portal_appearance.rs, an XDG desktop portal org.freedesktop.appearance color-scheme reply of 0 ("no preference", which GNOME's Default style and light-mode shells send) was conflated with an unanswered portal, so Cx::system_dark() fell back to dark and switching from dark (1) back to default (0) did not update. Chromium (ui/linux/portal_settings_linux.cc, SetColorScheme), Firefox (widget/gtk/nsLookAndFeel.cpp), and libadwaita (src/adw-style-manager.c) all treat only 1 as dark and resolve 0 and 2 to light once the portal answers, reserving the fallback for when no portal answers. Rune now separates the unanswered state from answered 0/2 (light) and 1 (dark), so Cx::system_dark() is false when the portal answers 0 while unreachable portals still fall back to dark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions