fix(matic): hibernate on battery lid close - #2094
Conversation
|
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
You do not have enough credits to review this pull request. Please purchase more credits to continue. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Disabled knowledge base sources:
📝 WalkthroughSummary by CodeRabbit
WalkthroughMatic’s systemd-logind configuration now hibernates when the lid closes on battery. The corresponding specification expects ChangesMatic lid policy
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| # Suspend on battery lid close; on AC, Hyprland locks on the lid switch event. | ||
| services.logind.settings.Login.HandleLidSwitch = "suspend"; | ||
| # Hibernate on battery lid close; on AC, Hyprland locks on the lid switch event. | ||
| services.logind.settings.Login.HandleLidSwitch = "hibernate"; |
There was a problem hiding this comment.
Hibernate has no backing swap on this host. named-hosts/matic/hardware-configuration.nix:44 declares swapDevices = [ ], and there is no boot.resumeDevice, no swap file, and no resume=/resume_offset= entry in boot.kernelParams (see named-hosts/matic/default.nix:58-63) — grepping swap|resume|hibernat across named-hosts/matic/ and hosts/ returns only the fprintd-resume unit and this new line.
When systemd-logind receives the lid-close event it will call hibernate.target, which systemd refuses with Not enough swap space for hibernation / Sleep verb "hibernate" not supported. Net effect on battery: closing the lid does nothing — the machine stays awake in your bag. That's a regression from the previous suspend behavior and a real thermal/battery risk.
Fix direction: either revert to suspend (or suspend-then-hibernate), or land the hibernation prerequisites first — e.g. add a swap partition/file sized for RAM plus boot.resumeDevice = "/dev/disk/by-uuid/..." (and resume_offset if using a swap file), ideally on an encrypted volume separate from the TPM2-auto-unlocked root.
| # Suspend on battery lid close; on AC, Hyprland locks on the lid switch event. | ||
| services.logind.settings.Login.HandleLidSwitch = "suspend"; | ||
| # Hibernate on battery lid close; on AC, Hyprland locks on the lid switch event. | ||
| services.logind.settings.Login.HandleLidSwitch = "hibernate"; |
There was a problem hiding this comment.
Heads-up on the security model: the root LUKS device auto-unlocks via TPM2 (named-hosts/matic/default.nix:44-47), which means whatever swap you end up putting the hibernation image on will also be transparently decrypted on next boot. If part of the motivation for moving to hibernate was "safer to leave the laptop shut for long periods," that's not really gained on this host versus suspend + LUKS — you'd want the hibernation swap on a separately-keyed encrypted volume (or bound to different PCRs / require a passphrase on resume) to get a real benefit. Latent today; becomes relevant the moment hibernation actually starts working.
Mesa DescriptionTL;DRChanged Matic's lid-close action from suspend to hibernate when on battery power to preserve sessions to disk, leaving AC-powered behavior unchanged. What changed?
Description generated by Mesa. Update settings |
Summary
Why
Matic should preserve the session to disk when its lid closes on battery instead of using suspend.
Validation
shellspec spec/matic_lid_policy_spec.shmake nix-format-checknixosConfigurations.matic.config.services.logind.settings.Login.HandleLidSwitchashibernateThe full Matic build was attempted but cannot realize an x86_64-linux Docker derivation from this aarch64-darwin host.
Summary by cubic
Switch Matic’s battery lid-close action from suspend to hibernate to save the session to disk. AC-powered behavior remains unchanged, and the lid-policy regression test now expects
HandleLidSwitch = "hibernate".Written for commit e35994f. Summary will update on new commits.