[PR #5684] fix(desktop): detect system dark mode on Linux #11529

Open
opened 2026-02-16 18:16:22 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/5684

State: open
Merged: No


Problem

On Linux, the desktop app ignores the system dark mode setting. The app always shows light theme even when the system is set to dark mode.

Root cause: WebKitGTK (used by Tauri on Linux) doesn't properly report prefers-color-scheme to CSS/JavaScript. It always returns light regardless of system settings.

Solution

  1. Detect the system color scheme in Rust using gsettings (GNOME) with GTK theme fallback
  2. Inject data-color-scheme attribute via initialization script before page load
  3. Add CSS selector html[data-color-scheme="dark"] to apply dark theme

Changes

  • packages/tauri/src-tauri/src/lib.rs - Add detect_linux_color_scheme() function
  • packages/ui/src/styles/theme.css - Add dark theme selector for data-color-scheme attribute

Testing

Tested on Fedora 42 with GNOME dark mode enabled.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5684 **State:** open **Merged:** No --- ## Problem On Linux, the desktop app ignores the system dark mode setting. The app always shows light theme even when the system is set to dark mode. **Root cause:** WebKitGTK (used by Tauri on Linux) doesn't properly report `prefers-color-scheme` to CSS/JavaScript. It always returns `light` regardless of system settings. ## Solution 1. Detect the system color scheme in Rust using `gsettings` (GNOME) with GTK theme fallback 2. Inject `data-color-scheme` attribute via initialization script before page load 3. Add CSS selector `html[data-color-scheme="dark"]` to apply dark theme ## Changes - `packages/tauri/src-tauri/src/lib.rs` - Add `detect_linux_color_scheme()` function - `packages/ui/src/styles/theme.css` - Add dark theme selector for `data-color-scheme` attribute ## Testing Tested on Fedora 42 with GNOME dark mode enabled.
yindo added the pull-request label 2026-02-16 18:16:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11529