swayidle: remove unnecessary config wrapper

This commit is contained in:
Robert Helgesson 2022-07-12 12:02:01 +02:00
parent 43ea4c5123
commit 45ef70cc73
Failed to generate hash of commit

View file

@ -1,55 +1,53 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
{ {
config = { services.swayidle = {
services.swayidle = { enable = true;
enable = true; package = config.lib.test.mkStubPackage { };
package = config.lib.test.mkStubPackage { }; timeouts = [
timeouts = [ {
{ timeout = 50;
timeout = 50; command = ''notify-send -t 10000 -- "Screen lock in 10 seconds"'';
command = ''notify-send -t 10000 -- "Screen lock in 10 seconds"''; }
} {
{ timeout = 60;
timeout = 60; command = "swaylock -fF";
command = "swaylock -fF"; }
} {
{ timeout = 300;
timeout = 300; command = ''swaymsg "output * dpms off"'';
command = ''swaymsg "output * dpms off"''; resumeCommand = ''swaymsg "output * dpms on"'';
resumeCommand = ''swaymsg "output * dpms on"''; }
} ];
]; events = [
events = [ {
{ event = "before-sleep";
event = "before-sleep"; command = "swaylock -fF";
command = "swaylock -fF"; }
} {
{ event = "lock";
event = "lock"; command = "swaylock -fF";
command = "swaylock -fF"; }
} ];
];
};
nmt.script = let
escapeForRegex = builtins.replaceStrings [ "'" "*" ] [ "'\\''" "\\*" ];
expectedArgs = escapeForRegex (lib.concatStringsSep " " [
"-w"
"timeout 50 'notify-send -t 10000 -- \"Screen lock in 10 seconds\"'"
"timeout 60 'swaylock -fF'"
"timeout 300 'swaymsg \"output * dpms off\"' resume 'swaymsg \"output * dpms on\"'"
"before-sleep 'swaylock -fF'"
"lock 'swaylock -fF'"
]);
in ''
serviceFile=home-files/.config/systemd/user/swayidle.service
assertFileExists $serviceFile
assertFileRegex $serviceFile 'ExecStart=.*/bin/swayidle ${expectedArgs}'
assertFileRegex $serviceFile 'Environment=.*PATH=${
lib.makeBinPath [ pkgs.bash ]
}'
'';
}; };
nmt.script = let
escapeForRegex = builtins.replaceStrings [ "'" "*" ] [ "'\\''" "\\*" ];
expectedArgs = escapeForRegex (lib.concatStringsSep " " [
"-w"
"timeout 50 'notify-send -t 10000 -- \"Screen lock in 10 seconds\"'"
"timeout 60 'swaylock -fF'"
"timeout 300 'swaymsg \"output * dpms off\"' resume 'swaymsg \"output * dpms on\"'"
"before-sleep 'swaylock -fF'"
"lock 'swaylock -fF'"
]);
in ''
serviceFile=home-files/.config/systemd/user/swayidle.service
assertFileExists $serviceFile
assertFileRegex $serviceFile 'ExecStart=.*/bin/swayidle ${expectedArgs}'
assertFileRegex $serviceFile 'Environment=.*PATH=${
lib.makeBinPath [ pkgs.bash ]
}'
'';
} }