xidlehook
Because xautolock is annoying to work with.
xidlehook is a general-purpose replacement for xautolock. It executes a command when the computer has been idle for a specified amount of time.
Improvements over xautolock:
- Allows "cancellers" which can undo a timer action when new user activity is detected.
- Unlimited amount of timers (provided necessary resources).
- Not specific to locking.
- Multiple instances can run at the same time.
- Optionally only run once.
- Optionally prevent locking when an application is fullscreen.
- Optionally prevent locking when any application plays audio.
Missing features:
- Magic corners.
- All the instance related stuff (you should use unix sockets with --socket).
Example
Here's a lock using i3lock, with screen dim support:
#!/usr/env/bin bash
# Only exported variables can be used within the timer's command.
# Run xidlehook
Note: Every command is passed through sh -c
, so you should be able to mostly use normal syntax.
Installation
Installation using cargo
:
Xidlehook with the default settings requires libXScrnSaver (or libxss) and
libpulseaudio. On debian/ubuntu, don't forget to install the -dev
versions,
also.
It's also available on Nix and the AUR (not officially maintained).
Or if you want to clone it manually:
Too bloaty?
Not using pulseaudio?
Disable that requirement completely with --no-default-features
!
This, however, will get rid of the --not-when-audio
option.
Socket API
The socket API is very simple. Each command is a single byte, sent over a unix
socket. Bind a file using --socket /path/to/xidlehook.sock
(where the path is
whatever you want), and then you can send one of the following bytes:
Byte | Command |
---|---|
0 | Deactivate |
1 | Activate |
2 | Run the timer command immediately |
For convenience, there is now an xidlehook-client (see #18), which will communicate with this API for you. See
xidlehook-client --help
for details.
A common use case of xidlehook
is using it to run a lockscreen. To then
manually lock the screen, you could bind this bash command to a shortcut:
xidlehook-client --trigger --socket /path/to/xidlehook.sock
Alternatively, you can use the API directly using, for example, socat
:
echo -ne "\x0" | socat - UNIX-CONNECT:/path/to/xidlehook.sock
(You have no reason to run this for the most cases anymore)