1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-09 12:49:44 +01:00
home-manager/modules/services/xscreensaver.nix

70 lines
1.7 KiB
Nix
Raw Normal View History

2017-01-07 19:16:26 +01:00
{ config, lib, pkgs, ... }:
with lib;
2019-04-22 22:42:42 +02:00
let
cfg = config.services.xscreensaver;
2020-02-02 00:39:17 +01:00
in {
meta.maintainers = [ maintainers.rycee ];
2017-01-07 19:16:26 +01:00
options = {
services.xscreensaver = {
enable = mkEnableOption "XScreenSaver";
2019-04-22 22:42:42 +02:00
settings = mkOption {
type = with types; attrsOf (either bool (either int str));
2020-02-02 00:39:17 +01:00
default = { };
2019-04-22 22:42:42 +02:00
example = {
mode = "blank";
lock = false;
fadeTicks = 20;
};
description = ''
The settings to use for XScreenSaver.
'';
};
package = mkOption {
type = with types; package;
default = pkgs.xscreensaver;
defaultText = lib.literalExpression "pkgs.xscreensaver";
description = "Which xscreensaver package to use.";
};
2017-01-07 19:16:26 +01:00
};
};
2019-04-22 22:42:42 +02:00
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.xscreensaver" pkgs
lib.platforms.linux)
];
# To make the xscreensaver-command tool available.
home.packages = [ cfg.package ];
2019-04-22 22:42:42 +02:00
xresources.properties =
mapAttrs' (n: nameValuePair "xscreensaver.${n}") cfg.settings;
2017-01-07 19:16:26 +01:00
systemd.user.services.xscreensaver = {
2020-02-02 00:39:17 +01:00
Unit = {
Description = "XScreenSaver";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
# Make sure the service is restarted if the settings change.
X-Restart-Triggers =
[ (builtins.hashString "md5" (builtins.toJSON cfg.settings)) ];
2020-02-02 00:39:17 +01:00
};
2017-01-07 19:16:26 +01:00
2020-02-02 00:39:17 +01:00
Service = {
ExecStart = "${cfg.package}/bin/xscreensaver -no-splash";
Environment = "PATH=${makeBinPath [ cfg.package ]}";
2020-02-02 00:39:17 +01:00
};
2017-01-07 19:16:26 +01:00
2020-02-02 00:39:17 +01:00
Install = { WantedBy = [ "graphical-session.target" ]; };
2017-01-07 19:16:26 +01:00
};
};
}