diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index 7f4f537e..930823ff 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -8,6 +8,8 @@ let cfg2 = config.gtk.gtk2; cfg3 = config.gtk.gtk3; + dag = config.lib.dag; + toGtk3Ini = generators.toINI { mkKeyValue = key: value: let @@ -27,6 +29,16 @@ let in "${n} = ${v'}"; + toDconfIni = generators.toINI { + mkKeyValue = key: value: + let + tweakVal = v: + if isString v then "'${v}'" + else toString v; + in + "${key}=${tweakVal value}"; + }; + fontType = types.submodule { options = { package = mkOption { @@ -141,6 +153,21 @@ in ~/.config/gtk-3.0/gtk.css. ''; }; + + waylandSupport = mkOption { + type = types.bool; + default = false; + description = '' + Support GSettings provider (dconf) in addition to + GtkSettings (INI file). This is needed for Wayland. + + Note, on NixOS the following line must be in the + system configuration: + + services.dbus.packages = [ pkgs.gnome3.dconf ]; + + ''; + }; }; }; }; @@ -159,6 +186,16 @@ in optionalAttrs (cfg.iconTheme != null) { gtk-icon-theme-name = cfg.iconTheme.name; }; + dconfIni = + optionalAttrs (cfg.font != null) + { font-name = cfg.font.name; } + // + optionalAttrs (cfg.theme != null) + { gtk-theme = cfg.theme.name; } + // + optionalAttrs (cfg.iconTheme != null) + { icon-theme = cfg.iconTheme.name; }; + optionalPackage = opt: optional (opt != null && opt.package != null) opt.package; in @@ -178,6 +215,23 @@ in toGtk3Ini { Settings = ini // cfg3.extraConfig; }; xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss; + + home.activation = mkIf cfg3.waylandSupport { + gtk3 = dag.entryAfter ["installPackages"] ( + let + iniText = toDconfIni { "/" = dconfIni; }; + iniFile = pkgs.writeText "gtk3.ini" iniText; + dconfPath = "/org/gnome/desktop/interface/"; + in + '' + if [[ -v DRY_RUN ]]; then + echo ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} "<" ${iniFile} + else + ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${iniFile} + fi + '' + ); + }; } ); }