Keep inhibits across daemon restarts
Save held inhibits to $XDG_RUNTIME_DIR/xautolock-inhibit.json and restore them on start if the previous instance stopped within --restore-window (default 30s) on the same bus and the senders are still connected. The file is touched every 10s while inhibits are held, so crashes are timed too.
This commit is contained in:
@@ -16,6 +16,7 @@ xautolock stays your locker; xautolock-inhibit only switches it off and on.
|
||||
- Runs `xautolock` only when the number of active requests goes from 0 to 1 or back to 0. Re-enabling waits a few seconds (`--release-delay`), because browsers send short bursts of requests when a video starts.
|
||||
- Pauses X blanking with `XScreenSaverSuspend`, the same mechanism mpv uses, instead of changing `xset` settings. The X server ends the pause by itself if the daemon exits or crashes.
|
||||
- Requests whose reason is on an ignore list (default: `Playing audio`) are accepted and logged, but don't block locking. Firefox-based browsers send one for audio playback, which would otherwise keep the screen unlocked while music plays with nobody at the computer.
|
||||
- Keeps the requests it holds in `$XDG_RUNTIME_DIR/xautolock-inhibit.json`, so a restarted or crashed daemon takes them over. They are taken over only if the previous daemon stopped at most 30 seconds ago (`--restore-window`) on the same session bus, and only for clients still connected. A request released while no daemon was running can't be seen, so an old file isn't trusted.
|
||||
- On exit (including SIGTERM), it re-enables xautolock. The systemd unit also runs `xautolock -enable` when it stops, as a fallback.
|
||||
- If another program (a desktop environment) already owns `org.freedesktop.ScreenSaver`, it exits with status 2 instead of taking over.
|
||||
|
||||
@@ -45,12 +46,13 @@ The unit has no `[Install]` section on purpose. Enabling it at login would also
|
||||
## Usage
|
||||
|
||||
```
|
||||
xautolock-inhibit [-i REASON] [--count-all] [-d SECONDS]
|
||||
xautolock-inhibit [-i REASON] [--count-all] [-d SECONDS] [--restore-window SECONDS]
|
||||
```
|
||||
|
||||
- `-i`, `--ignore-reason REASON`: request reason that doesn't block locking. Can be repeated; replaces the default (`Playing audio`).
|
||||
- `--count-all`: every request blocks locking; no reasons are ignored.
|
||||
- `-d`, `--release-delay SECONDS`: wait this long after the last release before re-enabling xautolock (default 5).
|
||||
- `--restore-window SECONDS`: take over requests from a previous daemon that stopped at most this long ago (default 30; 0 disables).
|
||||
|
||||
To change the options used by the service:
|
||||
|
||||
@@ -84,7 +86,7 @@ journalctl --user -u xautolock-inhibit
|
||||
|
||||
## Limitations
|
||||
|
||||
- Restarting the daemon loses the requests it holds; apps don't send them again. Avoid restarting it while a video or game is running.
|
||||
- A release sent while the daemon is down is lost: if the daemon is back within `--restore-window`, that request stays active until its app exits. After a longer stop, all held requests are dropped and apps don't send them again.
|
||||
- `SimulateUserActivity` is accepted but does nothing. Calls are logged once when a client starts sending them and once, with a count, after 5 minutes without any.
|
||||
- `GetActive` always returns `false`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user