Swayidle timeouts and events not triggering

I configured swayidle with the home manager module and for some reason, neither the idle timeouts nor the events I configured are triggering.

However, the swayidle process still starts and runs in the background and if I manually run swayidle in a terminal with my desired settings, then everything works just as I expect.

I have a flake-based setup, I use nixpkgs unstable, and I use Hyprland as a window manager.

My swayidle config is below. The timeouts are set really short for testing purposes. lockman.sh is a just custom script I wrote that runs swaylock along with pipes-rs as a screensaver.

{ ... }: {
  services.swayidle =
    let
      lockCommand = "lockman.sh";
    in
    {
      enable = true;
      systemdTarget = "hyprland-session.target";
      timeouts =
        let
          dpmsCommand = "hyprctl dispatch dpms";
        in
        [
          {
            # timeout = 300;
            timeout = 5;
            command = lockCommand;
          }
          {
            # timeout = 600;
            timeout = 10;
            command = "${dpmsCommand} off";
            resumeCommand = "${dpmsCommand} on";
          }
        ];
      events = [
        {
          event = "before-sleep";
          command = lockCommand;
        }
        {
          event = "lock";
          command = lockCommand;
        }
      ];
    };
}
1 Like

Never mind. The issue was that I needed to use the ${pkgs.<package>}/bin/<program> thing to give swayidle absolute paths to the commands to run. For the custom lock script, I just needed to put it in an overlay so it could be used as a package.

1 Like