From 33a2943e8cbbe876e15cc4e6dbb4b5c5ce484bc5 Mon Sep 17 00:00:00 2001 From: gnidorah Date: Sat, 22 Sep 2018 19:30:13 +0300 Subject: [PATCH] gtk: add support for wayland --- modules/misc/gtk.nix | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index 7f4f537ed..930823ff4 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 + '' + ); + }; } ); }