Skip to content

Add dark mode support (Windows + Linux #15

Description

@GraceDabbieri

I, Grace, noticed FastSMRW doesn't follow the system's dark/light theme on
Windows or Linux, and asked Claude to look into how to add it. Claude pulled
a local copy of the source tree and read through the relevant files to work
out the best approach before writing up the plan below.

CONTEXT

Dark mode isn't implemented on Windows or Linux yet (Android gets it for
free from the OS). Android's implementation is a platform API call with no
portable logic behind it, so it isn't something to reuse -- each desktop
front end needs its own detection, which is normal since this is
inherently platform I/O, not shared core logic.

LINUX

The GTK3 front end doesn't hardcode any colors, so it already renders
correctly under whatever theme is active -- it just needs to be told to
prefer the dark variant when the desktop wants dark, and to notice when
that changes live.

  • Detect via the freedesktop XDG Desktop Portal: call
    org.freedesktop.portal.Settings.Read("org.freedesktop.appearance",
    "color-scheme") at startup (0/1/2 = no preference/dark/light), and
    subscribe to its SettingChanged signal for live updates. This is D-Bus
    based, so it covers GNOME, KDE Plasma, Sway/wlroots, and others across
    both X11 and Wayland, rather than just one desktop environment.
  • Apply it with g_object_set(gtk_settings_get_default(),
    "gtk-application-prefer-dark-theme", prefer_dark, NULL) -- one call
    that covers every window and dialog.
  • linux/src/main.cpp already opens a session D-Bus connection for
    single-instance handling, so this reuses that same connection.
  • Fallback if no portal is running (minimal WMs like i3/dwm): read
    org.gnome.desktop.interface via GSettings; if that's unavailable too,
    leave the theme's own default alone rather than guessing.

WINDOWS

Win32 needs more manual work than GTK since there's no automatic
"dark variant" concept for standard controls:

  • Detect via the registry value AppsUseLightTheme under
    HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize, and
    listen for WM_SETTINGCHANGE to catch live theme switches.
  • Apply it with DwmSetWindowAttribute(..., DWMWA_USE_IMMERSIVE_DARK_MODE,
    ...) for dark title bars, and SetWindowTheme(hwnd, "DarkMode_Explorer",
    NULL) plus handling WM_CTLCOLOR*/WM_ERASEBKGND for control backgrounds
    and text, since standard Win32 controls don't re-theme themselves.

FOLLOW-UP

A manual override (Settings -> Auto / Light / Dark) could be added later,
stored in the existing shared "settings" object in config.json so both
platforms (and eventually macOS/iOS) can share the same key.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions