opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(desktop): detect system dark mode on Linux

Open tedin7 opened this issue 1 month ago • 2 comments

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.

tedin7 avatar Dec 17 '25 11:12 tedin7

A few things in flux atm, desktop guys requested I didn't merge PRs quite yet, they should be ready for contributions soon tho

rekram1-node avatar Dec 17 '25 16:12 rekram1-node

Ill have them review

rekram1-node avatar Dec 18 '25 16:12 rekram1-node