1
0
mirror of https://github.com/nix-community/home-manager synced 2024-07-04 20:33:27 +02:00
home-manager/tests/modules/services/swayidle/basic-configuration.nix
Jos van Bakel 65e5b835a9
swayidle: add module (#2610)
Swayidle is an idle management daemon for Wayland. This modules adds support for
running swayidle as a SystemD user unit and makes it configurable through
home-manager.
2022-01-03 12:03:20 -07:00

53 lines
1.4 KiB
Nix

{ config, pkgs, lib, ... }:
{
config = {
services.swayidle = {
enable = true;
package = config.lib.test.mkStubPackage { };
timeouts = [
{
timeout = 50;
command = ''notify-send -t 10000 -- "Screen lock in 10 seconds"'';
}
{
timeout = 60;
command = "swaylock -fF";
}
{
timeout = 300;
command = ''swaymsg "output * dpms off"'';
resumeCommand = ''swaymsg "output * dpms on"'';
}
];
events = [
{
event = "before-sleep";
command = "swaylock -fF";
}
{
event = "lock";
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}'
'';
};
}