PopOS 24/COSMIC: make the power button suspend and don't sleep when the lid closes
On this page
Upgraded PoOS recently and lost some features I iused to have…I wanted my laptop to suspend when I press the power button, and turn the screen off when I close the lid. COSMIC’s settings don’t allow me to set these any more!
I sent Claude looking in the source to see how big a patch it would be, but it turned out not to be as complex as all that…
Claude wrote this part. It sounds Claudy but I do not have time to make it sound like me, and I didn’t do it anyway!
Fix 1: power button suspends
PowerOff is one of the system_actions, a map from action name to command.
COSMIC reads the shipped map from /usr/share/cosmic/ and then overlays your
own, key by key, from ~/.config/cosmic/. The compositor watches that file, so
changes apply without logging out.
Create the file ~/.config/cosmic/com.system76.CosmicSettings.Shortcuts/v1/system_actions
containing:
{
PowerOff: "systemctl suspend",
}
Fix 2: lid does nothing
This part is plain systemd. Drop in /etc/systemd/logind.conf.d/90-ignore-lid.conf:
[Login]
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
sudo install -D -m644 90-ignore-lid.conf /etc/systemd/logind.conf.d/90-ignore-lid.conf
Make logind re-read its config (a reboot also works):
sudo systemctl kill -s HUP systemd-logind
Check it took:
busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager HandleLidSwitch
That should print s "ignore".
Summary
| Goal | Where | Change |
|---|---|---|
| Power button suspends | ~/.config/cosmic/com.system76.CosmicSettings.Shortcuts/v1/system_actions | PowerOff: "systemctl suspend" |
| Lid ignored | /etc/systemd/logind.conf.d/90-ignore-lid.conf | HandleLidSwitch*=ignore |
Both are ordinary config files, so they should survive COSMIC updates.