add Suspend (suspend to ram) to ShutdownModal and power button#23113
Open
macpaul wants to merge 6 commits intocockpit-project:mainfrom
Open
add Suspend (suspend to ram) to ShutdownModal and power button#23113macpaul wants to merge 6 commits intocockpit-project:mainfrom
macpaul wants to merge 6 commits intocockpit-project:mainfrom
Conversation
added 6 commits
April 9, 2026 22:09
Add a new 'suspend' prop to the ShutdownModal component to support suspending the system in addition to reboot and poweroff. When suspend mode is active: - Modal title changes to 'Suspend to RAM' - Submit button text changes to 'Suspend' - Immediate suspend uses 'systemctl suspend' - Delayed suspend uses 'systemd-run --unit=cockpit-suspend --on-active=Nm systemctl suspend' to create a transient timer that survives cockpit restarts - The message field is kept with a note that it has no effect for suspend operations, since wall(1) is not called during suspend The existing reboot/poweroff code paths are unchanged. Signed-off-by: Macpaul Lin <macpaul.lin@gmail.com>
Add a 'Suspend' option to the system overview shutdown dropdown and a corresponding status card for scheduled suspends. overview.jsx: - Check logind CanSuspend() via D-Bus on mount; only show 'Suspend' dropdown item when the hardware/kernel supports it (returns 'yes' or 'challenge') - Wire the 'Suspend' item to ShutdownModal with the new suspend prop shutdownStatus.tsx: - Add SuspendStatus component that detects an active cockpit-suspend transient timer via 'systemctl is-active cockpit-suspend.timer' - Display 'Scheduled suspend at <time>' with a MoonIcon in the Health card - Provide a 'Cancel suspend' button that stops the timer unit - Poll every 5 seconds since transient timers have no reliable file-watch equivalent unlike /run/systemd/shutdown/scheduled shutdownStatus.scss: - Add .suspend-status-icon colour rule alongside the existing shutdown/reboot icon styles healthCard.tsx: - Import and render the new SuspendStatus component after ShutDownStatus Signed-off-by: Macpaul Lin <macpaul.lin@gmail.com>
Verify that the suspend status banner in the Health card works end-to-end: - Schedule a suspend via systemd-run --unit=cockpit-suspend --on-active=10m to mimic what the cockpit UI does - Wait for the SuspendStatus component to detect the timer (polls every 5 seconds) and show 'Scheduled suspend' text - Reload the page and confirm the banner persists - Cancel via the UI cancel button and confirm the banner disappears - Assert that the cockpit-suspend.timer unit is no longer active Signed-off-by: Macpaul Lin <macpaul.lin@gmail.com>
Add two new test methods to a new TestSuspendDialog class: testSuspendDialogBasic: - Open the shutdown dropdown and click 'Suspend' - Verify the dialog title is 'Suspend to RAM' - Verify the submit button text is 'Suspend' - Verify the helper note about the message field is shown - Test delay option selection testSuspendDelayed: - Select a 5-minute delay and submit the suspend dialog - Verify that systemd-run created the cockpit-suspend.timer unit Both tests mock /usr/local/bin/systemctl to intercept the 'suspend' subcommand so the test VM is not actually suspended. Signed-off-by: Macpaul Lin <macpaul.lin@gmail.com>
Two bugs found during integration testing:
1. shutdownStatus.tsx: Fix fallback text from 'Suspend scheduled'
to 'Scheduled suspend' for consistency with 'Scheduled reboot'
and 'Scheduled poweroff' patterns. Also move the element id
'system-health-suspend-status-text' to a <span> wrapping only
the text, so the cancel button text is not included in the
selector's text content.
2. check-system-shutdown-restart: Replace locale-sensitive
text selectors ('button:contains(5 minutes)') with
position-based nth-child selectors that work correctly
regardless of the UI language (test VM uses Traditional
Chinese locale for translated strings).
Signed-off-by: Macpaul Lin <macpaul.lin@gmail.com>
On Ubuntu hosts, the autotools Makefile generated by the tasks container uses Fedora paths (e.g. /usr/sbin/mkdir) which are not present on Ubuntu. This causes `make dist` to fail when running test/image-prepare directly on the host. Add tools/make-dist-cached, a thin wrapper that returns the paths of already-built source tarballs (previously created inside the toolbox via tools/make-dist). Update test/image-prepare to use this wrapper so that image-prepare can be run on the Ubuntu host, which is needed to get KVM access via the host libvirt (the toolbox qemu does not expose the KVM virt type to its session libvirt driver). Signed-off-by: Macpaul Lin <macpaul.lin@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a suspend function to shutdown and power button.
This is useful for some home sever you just want it to suspend a while for saving power.
My next plan is to add a wake-up suspend to this if the commits have been accepted.
Thanks