nixos-config/home-manager/wayland/idle.nix

63 lines
1.4 KiB
Nix
Raw Normal View History

2024-05-13 16:34:57 -04:00
{ pkgs, lib, ... }:
let
2024-05-13 21:42:49 -04:00
wayland-idle-inhibitor = pkgs.stdenv.mkDerivation {
2024-05-13 16:34:57 -04:00
pname = "wayland-idle-inhibitor";
version = "1.0.0";
2024-05-13 21:42:49 -04:00
buildInputs = [
(pkgs.python312.withPackages (ps: with ps; [
pywayland
]))
2024-05-13 16:34:57 -04:00
];
dontUnpack = true;
installPhase = ''
install -Dm755 ${./idle/wayland-idle-inhibitor.py} \
$out/bin/wayland-idle-inhibitor
'';
2024-05-13 21:42:49 -04:00
};
2024-05-13 16:34:57 -04:00
in {
2024-05-13 16:35:33 -04:00
services.hypridle.enable = true;
services.hypridle.settings = {
general = {
before_sleep_cmd = "swaylock -f";
};
listener = [
{
timeout = 120;
2024-05-13 21:42:49 -04:00
on-timeout = "swaylock -f --grace=180";
2024-05-13 16:35:33 -04:00
}
{
timeout = 600;
on-timeout = "systemctl suspend";
}
];
};
2024-05-13 16:34:57 -04:00
# Idle inhibiting
home.packages = [
wayland-idle-inhibitor
];
systemd.user.services.wayland-pipewire-idle-inhibit = {
Install.WantedBy = [ "graphical-session.target" ];
Unit = {
Description = "Inhibit Wayland idling when media is played through pipewire";
Documentation= "https://github.com/rafaelrc7/wayland-pipewire-idle-inhibit";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
ConditionEnvironment = "WAYLAND_DISPLAY";
};
Service = {
ExecStart = "${lib.getExe pkgs.wayland-pipewire-idle-inhibit}";
Restart = "always";
RestartSec = "10";
};
};
}