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 {
|
2017-09-26 23:40:31 +02:00
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
2017-01-07 19:16:26 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-04-22 22:42:42 +02:00
|
|
|
config = mkIf cfg.enable {
|
2021-07-07 23:24:27 +02:00
|
|
|
assertions = [
|
|
|
|
(lib.hm.assertions.assertPlatform "services.xscreensaver" pkgs
|
|
|
|
lib.platforms.linux)
|
|
|
|
];
|
|
|
|
|
2018-03-01 23:21:45 +01:00
|
|
|
# To make the xscreensaver-command tool available.
|
|
|
|
home.packages = [ pkgs.xscreensaver ];
|
|
|
|
|
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" ];
|
2020-08-02 14:05:18 +02:00
|
|
|
|
|
|
|
# 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 = "${pkgs.xscreensaver}/bin/xscreensaver -no-splash";
|
2022-04-25 20:00:01 +02:00
|
|
|
Environment = "PATH=${makeBinPath [ pkgs.xscreensaver ]}";
|
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
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|