diff --git a/modules/home.nix b/modules/home.nix index 1d69ac8..6c5a469 100644 --- a/modules/home.nix +++ b/modules/home.nix @@ -323,6 +323,31 @@ in # Keep the GTK2 rc out of $HOME (default ~/.gtkrc-2.0). Setting this also # makes home-manager export GTK2_RC_FILES so GTK2 apps still find it. gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc"; + # The theme *name* alone isn't enough: the qgtk3 Qt bridge and apps' dark + # detection (e.g. keepassxc's "auto" theme) read this flag, not the name. + # Set it so both GTK apps and the Qt-via-gtk3 apps resolve to dark. + gtk3.extraConfig.gtk-application-prefer-dark-theme = true; + gtk4.extraConfig.gtk-application-prefer-dark-theme = true; + }; + + # The canonical dark/light signal on Wayland: apps query the xdg-desktop-portal + # Settings interface for org.freedesktop.appearance/color-scheme over D-Bus, and + # the gtk portal serves that from this dconf key. keepassxc's "auto" theme reads + # it (NixUtils::isDarkMode) and ignores the GTK theme name / Qt style entirely, + # so without this the portal reports 0 ("no preference") and keepass stays light. + # prefer-dark makes the portal report dark to every color-scheme-aware app. + dconf.settings."org/gnome/desktop/interface".color-scheme = "prefer-dark"; + + # Match the Qt apps (keepassxc, pinentry-qt, ssh askpass) to the GTK + # Adwaita-dark above, else they render the default light Fusion style. Use the + # gtk3 platform theme, not an adwaita *style* override: nixpkgs wraps Qt apps + # with a baked QT_PLUGIN_PATH pointing only at their build deps, so an external + # style plugin (adwaita-qt) is unreachable and QT_STYLE_OVERRIDE is silently + # ignored. The gtk3 plugin (libqgtk3) ships inside qtbase itself, so it's + # always on that path, and it reads the GTK theme (Adwaita-dark) directly. + qt = { + enable = true; + platformTheme.name = "gtk3"; }; # The home-manager Hyprland module below enables xdg.portal and pins the