diff --git a/modules/services/xsettingsd.nix b/modules/services/xsettingsd.nix
index 86336b212..56d83f92d 100644
--- a/modules/services/xsettingsd.nix
+++ b/modules/services/xsettingsd.nix
@@ -6,6 +6,20 @@ let
cfg = config.services.xsettingsd;
+ renderSettings = settings:
+ concatStrings (mapAttrsToList renderSetting settings);
+
+ renderSetting = key: value: ''
+ ${key} ${renderValue value}
+ '';
+
+ renderValue = value:
+ {
+ int = toString value;
+ bool = if value then "1" else "0";
+ string = ''"${value}"'';
+ }.${builtins.typeOf value};
+
in {
meta.maintainers = [ maintainers.imalison ];
@@ -21,6 +35,34 @@ in {
Package containing the xsettingsd program.
'';
};
+
+ settings = mkOption {
+ type = with types; attrsOf (oneOf [ bool int str ]);
+ default = { };
+ example = literalExample ''
+ {
+ "Net/ThemeName" = "Numix";
+ "Xft/Antialias" = true;
+ "Xft/Hinting" = true;
+ "Xft/RGBA" = "rgb";
+ }
+ '';
+ description = ''
+ Xsettingsd options for configuration file. See
+
+ for documentation on these values.
+ '';
+ };
+
+ configFile = mkOption {
+ type = types.nullOr types.package;
+ internal = true;
+ readOnly = true;
+ default = if cfg.settings == { } then
+ null
+ else
+ pkgs.writeText "xsettingsd.conf" (renderSettings cfg.settings);
+ };
};
};
@@ -41,7 +83,9 @@ in {
Service = {
Environment = "PATH=${config.home.profileDirectory}/bin";
- ExecStart = "${cfg.package}/bin/xsettingsd";
+ ExecStart = "${cfg.package}/bin/xsettingsd"
+ + optionalString (cfg.configFile != null)
+ " -c ${escapeShellArg cfg.configFile}";
Restart = "on-abort";
};
};
diff --git a/tests/default.nix b/tests/default.nix
index a6daa4c04..cf51d4aaa 100644
--- a/tests/default.nix
+++ b/tests/default.nix
@@ -139,6 +139,7 @@ import nmt {
./modules/services/window-managers/i3
./modules/services/window-managers/sway
./modules/services/wlsunset
+ ./modules/services/xsettingsd
./modules/systemd
./modules/targets-linux
] ++ lib.optionals enableBig [
diff --git a/tests/modules/services/xsettingsd/basic-configuration.conf b/tests/modules/services/xsettingsd/basic-configuration.conf
new file mode 100644
index 000000000..4e502c98f
--- /dev/null
+++ b/tests/modules/services/xsettingsd/basic-configuration.conf
@@ -0,0 +1,4 @@
+Net/ThemeName "Numix"
+Xft/Antialias 1
+Xft/Hinting 1
+Xft/RGBA "rgb"
diff --git a/tests/modules/services/xsettingsd/basic-configuration.nix b/tests/modules/services/xsettingsd/basic-configuration.nix
new file mode 100644
index 000000000..8ea2ec782
--- /dev/null
+++ b/tests/modules/services/xsettingsd/basic-configuration.nix
@@ -0,0 +1,26 @@
+{ config, pkgs, ... }:
+
+{
+ config = {
+ services.xsettingsd = {
+ enable = true;
+ package = config.lib.test.mkStubPackage { };
+ settings = {
+ "Net/ThemeName" = "Numix";
+ "Xft/Antialias" = true;
+ "Xft/Hinting" = true;
+ "Xft/RGBA" = "rgb";
+ };
+ };
+ nmt.script = ''
+ serviceFile=home-files/.config/systemd/user/xsettingsd.service
+
+ assertFileExists $serviceFile
+ assertFileRegex $serviceFile 'ExecStart=.*/bin/xsettingsd.*'
+
+ assertFileExists ${config.services.xsettingsd.configFile}
+ assertFileContent ${config.services.xsettingsd.configFile} \
+ ${./basic-configuration.conf}
+ '';
+ };
+}
diff --git a/tests/modules/services/xsettingsd/default.nix b/tests/modules/services/xsettingsd/default.nix
new file mode 100644
index 000000000..98c99f4c8
--- /dev/null
+++ b/tests/modules/services/xsettingsd/default.nix
@@ -0,0 +1 @@
+{ xsettingsd-basic-configuration = ./basic-configuration.nix; }