jD91mZM2/xidlehook

Add something like "-detectsleep" from xautolock

Closed this issue ยท 10 comments

Hey,

I noticed that xidlehook triggers a timer when the system resumes its state from a suspend.
While it's not a big problem for me, I think it would be nice if it could detect that a system was suspended, so the timers should be reset on the resume.

XAutolock has -detectsleep that:

Instructs xautolock to detect that computer has been put to sleep. This is done by detecting that time has jumped by more than 3 seconds. When this occurs, the lock timer is reset and locker program is not launched even if primary timeout has been reached. This option is typically used to avoid locker program to be launched when awaking a laptop computer.

Would it be possible to have something similar?

Thank you!

Feel free to PR, should be as simple as adding a check if it slept much longer than the intended amount of sleep (maybe like >3 seconds longer?), and calling the reset function which will start counting from zero again.

@jD91mZM2 I'd love to help, although I've no idea how to write in Rust. Feel free to close this issue if you don't want to implement this feature :)

Nah, I'll leave it open. Maybe someone else sees it!

As a workaround, one can run xidlehook-client reset-idle immediately after systemctl suspend --wait in the latest master

Update: Does master's --detect-sleep work for you? :)

Hey, thank you very much for this update. Unfortunately, I can't test it right now. The reason is stupid and plain - I use Nixos and didn't figure out (yet) how I can install software from different sources than my own or the official ones. Hope you understand :)

Hey, another NixOS user, that's awesome :)

Building

Legacy nix syntax for building:

nix-build https://github.com/jD91mZM2/xidlehook/archive/master.tar.gz
result/bin/xidlehook ...

New nix syntax for building:

nix build -f https://github.com/jD91mZM2/xidlehook/archive/master.tar.gz
result/bin/xidlehook ...

Newest nix syntax (only on an unstable nix version with support for nix flakes):

nix build github:jD91mZM2/xidlehook
result/bin/xidlehook ...

Installing

Install it into your user profile with

nix-env -if https://github.com/jD91mZM2/xidlehook/archive/master.tar.gz
xidlehook ...

Newest nix syntax (unstable nix only)

nix profile install github:jD91mZM2/xidlehook

In your configuration.nix:

{
  environment.systemPackages = [
    (import (pkgs.fetchFromGitHub {
      owner = "jD91mZM2";
      repo = "xidlehook";
      rev = "8c419d40c8e126c5d81eff0af5c8dfd98a0542a6";
      sha256 = "sha256-ym1yw0gf1i8FXQ2rP2u4mgJRO+3X6vKYWFVmkUxqMBw=";
    }))
  ];
}

@jD91mZM2 thanks for the instructions. Sometimes I just can't believe it can be this easy. I've updated the application, will come back to you in few days. Thank you!

New update was released, and is making its way into nixpkgs

Awesome, thanks! So, to just let you know, I didn't have any issues with the package :) When the system was resumed, the timers reset correctly. Thank you!