Merge pull request #61311 from turboMaCk/xss-lock-locker-options
xss-lock: improve locker options passing
This commit is contained in:
commit
fa2c6dc3c2
@ -8,12 +8,23 @@ in
|
|||||||
{
|
{
|
||||||
options.programs.xss-lock = {
|
options.programs.xss-lock = {
|
||||||
enable = mkEnableOption "xss-lock";
|
enable = mkEnableOption "xss-lock";
|
||||||
|
|
||||||
lockerCommand = mkOption {
|
lockerCommand = mkOption {
|
||||||
default = "${pkgs.i3lock}/bin/i3lock";
|
default = "${pkgs.i3lock}/bin/i3lock";
|
||||||
example = literalExample ''''${pkgs.i3lock-fancy}/bin/i3lock-fancy'';
|
example = literalExample ''''${pkgs.i3lock-fancy}/bin/i3lock-fancy'';
|
||||||
type = types.string;
|
type = types.string;
|
||||||
description = "Locker to be used with xsslock";
|
description = "Locker to be used with xsslock";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extraOptions = mkOption {
|
||||||
|
default = [ ];
|
||||||
|
example = [ "--ignore-sleep" ];
|
||||||
|
type = types.listOf types.str;
|
||||||
|
description = ''
|
||||||
|
Additional command-line arguments to pass to
|
||||||
|
<command>xss-lock</command>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
@ -21,7 +32,13 @@ in
|
|||||||
description = "XSS Lock Daemon";
|
description = "XSS Lock Daemon";
|
||||||
wantedBy = [ "graphical-session.target" ];
|
wantedBy = [ "graphical-session.target" ];
|
||||||
partOf = [ "graphical-session.target" ];
|
partOf = [ "graphical-session.target" ];
|
||||||
serviceConfig.ExecStart = "${pkgs.xss-lock}/bin/xss-lock ${cfg.lockerCommand}";
|
serviceConfig.ExecStart = with lib;
|
||||||
|
strings.concatStringsSep " " ([
|
||||||
|
"${pkgs.xss-lock}/bin/xss-lock"
|
||||||
|
] ++ (map escapeShellArg cfg.extraOptions) ++ [
|
||||||
|
"--"
|
||||||
|
cfg.lockerCommand
|
||||||
|
]);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -6,19 +6,35 @@ with lib;
|
|||||||
name = "xss-lock";
|
name = "xss-lock";
|
||||||
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ma27 ];
|
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ma27 ];
|
||||||
|
|
||||||
machine = {
|
nodes = {
|
||||||
|
simple = {
|
||||||
imports = [ ./common/x11.nix ./common/user-account.nix ];
|
imports = [ ./common/x11.nix ./common/user-account.nix ];
|
||||||
programs.xss-lock.enable = true;
|
programs.xss-lock.enable = true;
|
||||||
services.xserver.displayManager.auto.user = "alice";
|
services.xserver.displayManager.auto.user = "alice";
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
custom_lockcmd = { pkgs, ... }: {
|
||||||
$machine->start;
|
imports = [ ./common/x11.nix ./common/user-account.nix ];
|
||||||
$machine->waitForX;
|
services.xserver.displayManager.auto.user = "alice";
|
||||||
$machine->waitForUnit("xss-lock.service", "alice");
|
|
||||||
|
|
||||||
$machine->fail("pgrep xlock");
|
programs.xss-lock = {
|
||||||
$machine->succeed("su -l alice -c 'xset dpms force standby'");
|
enable = true;
|
||||||
$machine->waitUntilSucceeds("pgrep i3lock");
|
extraOptions = [ "-n" "${pkgs.libnotify}/bin/notify-send 'About to sleep!'"];
|
||||||
|
lockerCommand = "${pkgs.xlockmore}/bin/xlock -mode ant";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
startAll;
|
||||||
|
|
||||||
|
${concatStringsSep "\n" (mapAttrsToList (name: lockCmd: ''
|
||||||
|
${"$"+name}->start;
|
||||||
|
${"$"+name}->waitForX;
|
||||||
|
${"$"+name}->waitForUnit("xss-lock.service", "alice");
|
||||||
|
${"$"+name}->fail("pgrep ${lockCmd}");
|
||||||
|
${"$"+name}->succeed("su -l alice -c 'xset dpms force standby'");
|
||||||
|
${"$"+name}->waitUntilSucceeds("pgrep ${lockCmd}");
|
||||||
|
'') { simple = "i3lock"; custom_lockcmd = "xlock"; })}
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user