mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-07 17:41:03 +01:00
swayidle: minor cleanups
This commit is contained in:
parent
4803bf558b
commit
0b052dd811
2 changed files with 34 additions and 31 deletions
|
|
@ -3,7 +3,7 @@
|
|||
{
|
||||
services.swayidle = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { };
|
||||
package = config.lib.test.mkStubPackage { outPath = "@swayidle@"; };
|
||||
timeouts = [
|
||||
{
|
||||
timeout = 50;
|
||||
|
|
@ -31,24 +31,30 @@
|
|||
];
|
||||
};
|
||||
|
||||
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 ''
|
||||
nmt.script = ''
|
||||
serviceFile=home-files/.config/systemd/user/swayidle.service
|
||||
|
||||
assertFileExists $serviceFile
|
||||
assertFileRegex $serviceFile 'ExecStart=.*/bin/swayidle ${expectedArgs}'
|
||||
assertFileRegex $serviceFile 'Restart=always'
|
||||
assertFileRegex $serviceFile 'Environment=.*PATH=${
|
||||
lib.makeBinPath [ pkgs.bash ]
|
||||
}'
|
||||
assertFileExists "$serviceFile"
|
||||
|
||||
serviceFileNormalized="$(normalizeStorePaths "$serviceFile")"
|
||||
|
||||
assertFileContent "$serviceFileNormalized" ${
|
||||
builtins.toFile "expected.service" ''
|
||||
[Install]
|
||||
WantedBy=graphical-session.target
|
||||
|
||||
[Service]
|
||||
Environment=PATH=/nix/store/00000000000000000000000000000000-bash/bin
|
||||
ExecStart=@swayidle@/bin/dummy -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'
|
||||
Restart=always
|
||||
Type=simple
|
||||
|
||||
[Unit]
|
||||
ConditionEnvironment=WAYLAND_DISPLAY
|
||||
Description=Idle manager for Wayland
|
||||
Documentation=man:swayidle(1)
|
||||
PartOf=graphical-session.target
|
||||
''
|
||||
}
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue