at master 1.3 kB view raw
1{ 2 config, 3 pkgs, 4 lib, 5 ... 6}: 7 8let 9 cfg = config.programs.xss-lock; 10in 11{ 12 options.programs.xss-lock = { 13 enable = lib.mkEnableOption "xss-lock"; 14 15 lockerCommand = lib.mkOption { 16 default = "${pkgs.i3lock}/bin/i3lock"; 17 defaultText = lib.literalExpression ''"''${pkgs.i3lock}/bin/i3lock"''; 18 example = lib.literalExpression ''"''${pkgs.i3lock-fancy}/bin/i3lock-fancy"''; 19 type = lib.types.separatedString " "; 20 description = "Locker to be used with xsslock"; 21 }; 22 23 extraOptions = lib.mkOption { 24 default = [ ]; 25 example = [ "--ignore-sleep" ]; 26 type = lib.types.listOf lib.types.str; 27 description = '' 28 Additional command-line arguments to pass to 29 {command}`xss-lock`. 30 ''; 31 }; 32 }; 33 34 config = lib.mkIf cfg.enable { 35 systemd.user.services.xss-lock = { 36 description = "XSS Lock Daemon"; 37 wantedBy = [ "graphical-session.target" ]; 38 partOf = [ "graphical-session.target" ]; 39 serviceConfig.ExecStart = builtins.concatStringsSep " " ( 40 [ 41 "${pkgs.xss-lock}/bin/xss-lock" 42 "--session \${XDG_SESSION_ID}" 43 ] 44 ++ (builtins.map lib.escapeShellArg cfg.extraOptions) 45 ++ [ 46 "--" 47 cfg.lockerCommand 48 ] 49 ); 50 serviceConfig.Restart = "always"; 51 }; 52 }; 53}