From 744a2c2ed4e8d253d7cbe85895dd1c70b53f4973 Mon Sep 17 00:00:00 2001 From: rope Date: Mon, 10 Aug 2026 10:18:10 +0100 Subject: [PATCH] kayla: seed chrome's GTK theme via initial_preferences next to the binary --- hosts/FredOS-Kayla.nix | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/hosts/FredOS-Kayla.nix b/hosts/FredOS-Kayla.nix index 41a495c..bdc82b8 100644 --- a/hosts/FredOS-Kayla.nix +++ b/hosts/FredOS-Kayla.nix @@ -3,6 +3,27 @@ # FredOS-Gaming/FredOS-Macbook and stay off here). Windows refugees get a # taskbar, a start menu and a settings app that look like what they left. { config, pkgs, lib, ... }: +let + # Under KDE, Chrome's GetDefaultSystemTheme() (ui/linux/linux_ui_factory.cc) + # hardcodes SystemTheme::kQt for every KDE* desktop — it reads only the + # detected desktop environment. No policy and no command-line switch changes + # that default (--ui-toolkit picks which backend gets built, not the pref), + # so the profile pref is the only lever. + # + # Chrome seeds a new profile from `initial_preferences`, which it looks for + # in DIR_EXE — the directory holding the binary (first_run_internal_linux.cc) + # — so it has to be baked into the package, not dropped in /etc. Everything + # outside the "distribution" key is copied into the profile on first run. + # + # system_theme: 0 = Classic, 1 = GTK, 2 = Qt (ui/color/system_theme.h). + chromeGtkDefault = pkgs.google-chrome.overrideAttrs (old: { + postInstall = (old.postInstall or "") + '' + cp ${pkgs.writeText "chrome-initial-preferences" (builtins.toJSON { + extensions.theme.system_theme = 1; + })} $out/share/google/chrome/initial_preferences + ''; + }); +in { config = lib.mkIf (config.networking.hostName == "FredOS-Kayla") { services.displayManager.sddm = { @@ -59,12 +80,7 @@ stylix.targets.chromium.enable = false; environment.systemPackages = with pkgs; [ - # Chrome picks its toolkit from the desktop environment, and under KDE - # that's the Qt backend (hence the libqt{5,6}_shim.so it ships) — which - # is what's drawing the odd decorations. --ui-toolkit overrides that - # detection, so it uses GTK, i.e. the adw-gtk3 theme stylix already - # writes. No manual trip through Settings → Appearance. - (google-chrome.override { commandLineArgs = "--ui-toolkit=gtk"; }) + chromeGtkDefault spotify vesktop faugus-launcher