CachyOS / CachyOS/CachyOS-Settings
Closing laptop lid during shutdown suspends the system instead of completing poweroff
- Dominant language
- Shell
- Stars
- 443
- Forks
- 76
- PR merge metrics
- No merged PRs in 30d
Description
**Description:**
If you initiate a shutdown (from the KDE menu or via `systemctl poweroff`) and close the laptop lid before the shutdown fully completes, the system goes to sleep instead of powering off. This happens because the lid-close event races with the ongoing shutdown logind processes the lid switch and suspends the machine before the poweroff finishes.
I ran into this on battery I hit Shut Down, closed my lid, and walked away expecting it to turn off. Came back later to find it had just been sleeping the whole time, draining battery.
**Root Cause:**
Two things contribute to this:
1. CachyOS desktop ships no logind drop-in config at all. The systemd default `LidSwitchIgnoreInhibited=yes` means logind ignores all inhibitors (including KDE PowerDevil's `handle-lid-switch` block lock) when a lid switch event comes in. So even during an active shutdown, closing the lid triggers suspend.
2. The default `powerdevilrc` that ships with CachyOS (or KDE's own default) doesn't set an explicit `LidAction` under `[Battery][SuspendAndShutdown]` or `[LowBattery][SuspendAndShutdown]`, leaving the behavior undefined on battery.
**Suggested Fix:**
Ship a logind drop-in in the `CachyOS-Settings` package, something like `/etc/systemd/logind.conf.d/10-cachyos-desktop.conf`:
```ini
[Login]
LidSwitchIgnoreInhibited=no
InhibitDelayMaxSec=10
```
Setting `LidSwitchIgnoreInhibited=no` makes logind respect the inhibitor locks that KDE PowerDevil (and systemd's own shutdown sequence) already hold. This way, closing the lid during a shutdown or reboot is simply ignored, and the poweroff completes normally.
Optionally, bumping `InhibitDelayMaxSec` from the default 5s to 10s gives services a bit more breathing room during shutdown before delayed inhibitors get overridden.
**Side note for CachyOS-Handheld:**
The handheld `steam-deckify.conf` sets `HandlePowerKey=ignore` (so powerbuttond can handle it), but doesn't set `HandleLidSwitch=ignore` same race condition could happen there too, though Steam might handle it internally.
**System Info:**
- CachyOS (KDE Plasma, Wayland)
- systemd with default logind.conf (no drop-ins)
- PowerDevil managing power events
NB: **Used AI to write this into a MD file. Expect some errors!**
Contributor guide
Research direction
Inspect the CachyOS-Settings package layout and the proposed /etc/systemd/logind.conf.d/10-cachyos-desktop.conf drop-in, then review how existing settings are packaged. Verify that closing the lid during shutdown or reboot no longer suspends the system and that poweroff completes normally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100