Add xss-lock backend and rename to xidle-inhibit
The backend comes from ~/.config/xidle-inhibit/config, else the installed locker. With xss-lock, pausing X blanking alone blocks locking and Lock uses loginctl; the unit's ExecStopPost runs --cleanup. Inhibits from the old xautolock-inhibit state file are taken over once. Also fix mypy with pygobject-stubs 2.19.
This commit is contained in:
@@ -1,28 +1,31 @@
|
||||
# xautolock-inhibit
|
||||
# xidle-inhibit
|
||||
|
||||
Makes screen locking with `xautolock` respect the "don't lock the screen" requests that apps send, on X11 sessions without a desktop environment (for example a plain window manager like xmonad).
|
||||
Makes screen locking with `xautolock` or `xss-lock` respect the "don't lock the screen" requests that apps send, on X11 sessions without a desktop environment (for example a plain window manager like xmonad).
|
||||
|
||||
Browsers, Steam, gamemode and other apps ask the desktop not to lock or blank the screen while a video or game is running, through the D-Bus service `org.freedesktop.ScreenSaver`. Without a desktop environment nothing provides that service, so the requests are dropped and the screen locks in the middle of a video. xautolock-inhibit provides it:
|
||||
Browsers, Steam, gamemode and other apps ask the desktop not to lock or blank the screen while a video or game is running, through the D-Bus service `org.freedesktop.ScreenSaver`. Without a desktop environment nothing provides that service, so the requests are dropped and the screen locks in the middle of a video. xidle-inhibit provides it:
|
||||
|
||||
- While at least one request is active, it runs `xautolock -disable` and pauses X screen blanking and DPMS.
|
||||
- When the last request is released, it waits a few seconds, then runs `xautolock -enable` and resumes blanking.
|
||||
- While at least one request is active, it pauses X screen blanking and DPMS, and with xautolock also runs `xautolock -disable`. xss-lock locks when the X screensaver starts, so pausing it is enough.
|
||||
- When the last request is released, it waits a few seconds, then resumes blanking (and runs `xautolock -enable`).
|
||||
|
||||
xautolock stays your locker; xautolock-inhibit only switches it off and on.
|
||||
Your locker setup stays as it is; xidle-inhibit only holds it off.
|
||||
|
||||
Formerly `xautolock-inhibit`, which supported only xautolock.
|
||||
|
||||
## How it works
|
||||
|
||||
- Owns `org.freedesktop.ScreenSaver` on the session bus at both `/org/freedesktop/ScreenSaver` and `/ScreenSaver` (apps differ on the path), and implements `Inhibit` and `UnInhibit`.
|
||||
- Owns `org.freedesktop.ScreenSaver` on the session bus at both `/org/freedesktop/ScreenSaver` and `/ScreenSaver` (apps differ on the path), and implements `Inhibit`, `UnInhibit` and `Lock`.
|
||||
- Tracks requests per D-Bus client. If a client disconnects without releasing them (for example a browser crash), its requests are released.
|
||||
- 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.
|
||||
- Blocks and unblocks only when the number of active requests goes from 0 to 1 or back to 0. Unblocking 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.
|
||||
- Keeps the requests it holds in `$XDG_RUNTIME_DIR/xidle-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.
|
||||
- With xautolock, it re-enables xautolock on exit (including SIGTERM). The systemd unit also runs `xidle-inhibit --cleanup` when it stops, which does the same, as a fallback.
|
||||
- `Lock` runs `xautolock -locknow`, or `loginctl lock-session` with xss-lock.
|
||||
- If another program (a desktop environment) already owns `org.freedesktop.ScreenSaver`, it exits with status 2 instead of taking over.
|
||||
|
||||
## Requirements
|
||||
|
||||
- `xautolock`, already running in the session
|
||||
- `xautolock` or `xss-lock`, already running in the session
|
||||
- `python`, `python-gobject`
|
||||
- `libx11`, `libxss`
|
||||
|
||||
@@ -36,42 +39,72 @@ makepkg -si
|
||||
|
||||
Or, with aurutils, build it into a local repository with `aur build` and install it with pacman.
|
||||
|
||||
Then start it from your window manager's startup, after `xautolock`. For xmonad:
|
||||
Then start it from your window manager's startup, after the locker. For xmonad with xautolock:
|
||||
|
||||
```haskell
|
||||
spawnOnce "xautolock -time 10 -locker slock -detectsleep"
|
||||
spawnOnce "systemctl --user start xautolock-inhibit"
|
||||
spawnOnce "systemctl --user start xidle-inhibit"
|
||||
```
|
||||
|
||||
With xss-lock, the lock timeout is the X screensaver timeout (`xset s`):
|
||||
|
||||
```haskell
|
||||
spawnOnce "xset s 600"
|
||||
spawnOnce "xss-lock -- slock"
|
||||
spawnOnce "systemctl --user start xidle-inhibit"
|
||||
```
|
||||
|
||||
The unit has no `[Install]` section on purpose. Enabling it at login would also start it in a desktop environment, or before X is up; starting it from the window manager limits it to that session. The user service manager needs `DISPLAY` (and `XAUTHORITY`) in its environment, which `/etc/X11/xinit/xinitrc.d/50-systemd-user.sh` sets up for `startx` sessions.
|
||||
|
||||
### Upgrading from xautolock-inhibit
|
||||
|
||||
The package replaces `xautolock-inhibit`. After upgrading, change the `systemctl --user start` line in your window manager's startup, then switch the running daemon:
|
||||
|
||||
```
|
||||
systemctl --user stop xautolock-inhibit
|
||||
systemctl --user start xidle-inhibit
|
||||
```
|
||||
|
||||
Requests held by the old daemon are taken over if the new one starts within `--restore-window`.
|
||||
|
||||
## Configuration
|
||||
|
||||
The backend is set in `~/.config/xidle-inhibit/config` (`$XDG_CONFIG_HOME`):
|
||||
|
||||
```
|
||||
backend = xss-lock
|
||||
```
|
||||
|
||||
Values are `xautolock` and `xss-lock`. Without the file, xidle-inhibit uses whichever of the two is installed, and xautolock if both are. Restart the service after changing it.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
xautolock-inhibit [-i REASON] [--count-all] [-d SECONDS] [--restore-window SECONDS]
|
||||
xidle-inhibit [-i REASON] [--count-all] [-d SECONDS] [--restore-window SECONDS] [--cleanup]
|
||||
```
|
||||
|
||||
- `-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).
|
||||
- `-d`, `--release-delay SECONDS`: wait this long after the last release before unblocking locking (default 5).
|
||||
- `--restore-window SECONDS`: take over requests from a previous daemon that stopped at most this long ago (default 30; 0 disables).
|
||||
- `--cleanup`: run `xautolock -enable` if xautolock is the backend, then exit. Used by the unit's `ExecStopPost`.
|
||||
|
||||
To change the options used by the service:
|
||||
|
||||
```
|
||||
systemctl --user edit xautolock-inhibit.service
|
||||
systemctl --user edit xidle-inhibit.service
|
||||
```
|
||||
|
||||
```ini
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/usr/bin/xautolock-inhibit --count-all
|
||||
ExecStart=/usr/bin/xidle-inhibit --count-all
|
||||
```
|
||||
|
||||
Every request, release and xautolock call is logged to the journal:
|
||||
Every request, release and locker command is logged to the journal:
|
||||
|
||||
```
|
||||
journalctl --user -u xautolock-inhibit
|
||||
journalctl --user -u xidle-inhibit
|
||||
```
|
||||
|
||||
## App notes
|
||||
@@ -89,6 +122,7 @@ journalctl --user -u xautolock-inhibit
|
||||
## Limitations
|
||||
|
||||
- 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.
|
||||
- With xss-lock, requests block only the idle timeout: suspending, or `loginctl lock-session` from elsewhere, still locks.
|
||||
- `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