feat: hypridle init config

This commit is contained in:
ooks-io 2024-02-23 21:08:49 +13:00
parent 501c7fdf07
commit 4e20345a93
4 changed files with 80 additions and 12 deletions

View file

@ -1,12 +1,22 @@
{ lib, config, inputs, ... }:
{ lib, config, inputs, pkgs, ... }:
let
cfg = config.homeModules.desktop.wayland.lockscreen.hyprlock;
inherit (config.colorscheme) colors;
suspendScript = pkgs.writeShellScript "suspend-script" ''
${pkgs.pipewire}/bin/pw-cli i all | ${pkgs.ripgrep}/bin/rg running
# only suspend if audio isn't running
if [ $? == 1 ]; then
${pkgs.systemd}/bin/systemctl suspend
fi
'';
in
{
imports = [ inputs.hyprlock.homeManagerModules.hyprlock ];
imports = [
inputs.hyprlock.homeManagerModules.default
inputs.hypridle.homeManagerModules.default
];
config = lib.mkIf cfg.enable {
home.sessionVariables.LOCKER = "hyprlock";
@ -67,7 +77,17 @@ in
}
];
};
};
services.hypridle = {
enable = true;
beforeSleepCmd = "${pkgs.systemd}/bin/loginctl lock-session";
lockCmd = lib.getExe config.programs.hyprlock.package;
listeners = [
{
timeout = 330;
onTimeout = suspendScript.outPath;
}
];
};
};
}