Skip to content

[Bug]: Linux keep-awake's sleep block inhibitor prevents lid-close suspend on KDE, contradicting the setting's description #41016

Open

Description

@deathpie

Before submitting

  • I searched existing issues, discussions, and PRs and did not find a duplicate.

Area

apps/server

What happened

With Keep awake while agents work enabled (the default), closing the laptop lid does not suspend the machine on Linux/KDE. The desktop power manager's lid action is set to Sleep, but its suspend request is refused by logind because the T3 server holds a block inhibitor on sleep.

The setting's own description says:

Closing a laptop lid still puts it to sleep.

That is true on the other platforms by construction. macOS uses caffeinate -i and Windows uses SetThreadExecutionState(ES_SYSTEM_REQUIRED), which only prevent idle system sleep, so a user-initiated lid close still sleeps. On Linux the server instead runs:

systemd-inhibit --what=sleep --who="T3 Code" --why="Agents are working" --mode=block sh -c 'echo && exec tail --pid=<serverPid> -f /dev/null'

A block inhibitor on sleep makes logind refuse every suspend request, including the one issued by the desktop's power manager when the lid closes. So on Linux the setting silently disables lid-close suspend, which is stricter than both its description and the macOS/Windows behaviour.

Steps to reproduce

  1. Linux with a lid switch; KDE Plasma (Wayland) desktop power management.
  2. In System Settings → Power Management, set "When laptop lid closed" to Sleep (confirm lidAction = 1 and triggersLidAction = true on org.kde.Solid.PowerManagement.Actions.HandleButtonEvents).
  3. Leave Keep awake while agents work enabled and start a local agent turn on this server.
  4. Close the lid and wait. Nothing suspends: no PM: suspend entry in the kernel log, and logind only records Lid closed..

Confirm the blocker while the turn is running:

$ systemd-inhibit --list --what=sleep
WHO       UID  USER      PID   COMM             WHAT   WHY                MODE
...
T3 Code   1000 deathpie  4428  systemd-inhibit  sleep  Agents are working block

$ busctl call org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager CanSuspend
s "inhibited"

Quit the app (or let the 60 s release grace elapse) and the identical lid close works:

Lid closed              14:18:04
PM: suspend entry (deep) 14:18:05
PM: suspend exit        14:18:12
Lid opened              14:18:12

Why LidSwitchIgnoreInhibited does not save it

logind's lid handling ignores inhibitors by default, but on KDE it never runs: PowerDevil takes a block inhibitor on handle-lid-switch ("KDE handles power events") so that logind stays out of lid handling, then asks logind to suspend when the lid closes. That request is a normal suspend request, so it is subject to the sleep block inhibitor. Any desktop that routes lid close through the logind Suspend() method behaves the same way.

Expected behavior

Closing the lid suspends the machine while agents work, matching the setting's description and the macOS/Windows behaviour. At minimum, the Linux limitation should be documented in the setting text, since on Linux the toggle currently also disables lid-close suspend.

Version

t3code-nightly-bin 0.1.12_nightly.20261122.5098-1. This build already includes #39490 — the live argv is --what=sleep with no idle, so this is not the idle-lock issue from #39486.

Environment

CachyOS (Arch-based), KDE Plasma 6.8.3 on Wayland, systemd 262 (262.2-1-arch), kernel 7.3.5-2-cachyos, laptop with an ACPI lid switch (LID0).

Evidence gathered

  • systemd-inhibit --list --what=sleep shows T3 Code … systemd-inhibit sleep "Agents are working" block for the whole duration of a turn plus ~60 s.
  • CanSuspend returns inhibited while it is held, and yes once it is released.
  • The lock is re-acquired within seconds if the helper is killed while a run is active.
  • Lid close with T3 not running: deep suspend entry and clean exit (log above).
  • Lid close with T3 running: logind logs Lid closed. and nothing else.

Related issues and PRs

Disclosure

Investigated and written with an AI agent operating the affected machine; every command output quoted above was observed on the real host, not inferred from source.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions