feat(power): backport configurable power-button controls to 7.3 - #2715
feat(power): backport configurable power-button controls to 7.3#2715Eli Bosley (elibosley) wants to merge 7 commits into
Conversation
Rename the "Power Mode" settings page to "Power Options" and turn it into a tabbed page with two tabs: - Power Mode - the existing CPU governor controls (moved verbatim) - Power Button - new setting to choose what the physical power button does The power button behavior (Shut down / Do nothing) is stored in the [powermode] section of dynamix.cfg and read live by the ACPI handler on each press, so changes take effect without a reload or reboot. A setting-aware ACPI handler (etc/acpi/unraid_power_handler.sh) is installed over the stock Slackware acpi_handler.sh at boot by rc.acpid, so it reliably overrides the default poweroff regardless of package install order. This mirrors how rc.cpufreq applies the [powermode] governor setting at boot. Closes OS-463 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A physical power press fires both an ACPI event (handled by acpid) and an input key event handled by elogind, whose default HandlePowerKey=poweroff shuts the system down regardless of the acpid handler. Ship a logind.conf.d drop-in setting HandlePowerKey/HandlePowerKeyLongPress to ignore so acpid is the sole authority over the power button, making the "Do nothing" Power Options setting actually take effect. Verified on hardware: elogind D-Bus HandlePowerKey now reports "ignore". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Power Button now offers Shut down, Reboot, Sleep (suspend, shown only when the kernel supports suspend-to-RAM), and Do nothing. Plugins can add or override actions without touching core: - WebUI: PowerButton.page includes plugins/*/include/powerbutton-option.php (and powerbutton-extra.php for action-specific fields). - Action: unraid_power_handler.sh dispatches to /etc/acpi/powerbutton.d/<action> for non-builtin actions, and the builtin "sleep" defers to powerbutton.d/sleep when present (so the S3 Sleep plugin can do array-aware prep). Contract documented in /etc/acpi/powerbutton.d/README. This lets the User Scripts plugin add a "Run script" action in its own repo rather than coupling it into core. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drop the built-in Sleep option and its generic echo-mem suspend. A core suspend bypasses the array/Docker/VM/wake prep the S3 Sleep plugin performs and is hardware-fragile, and Unraid intentionally ships S3 sleep as a plugin. Core now offers only the trivially-safe primitives (Shut down, Reboot, Do nothing). Sleep is added by the S3 Sleep plugin via the same extension hook used for other plugin actions: it ships /etc/acpi/powerbutton.d/sleep and a powerbutton-option.php fragment. The handler already routes powerbutton="sleep" through the plugin dir. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
QA (jorgeb) failed PR 2671. Fixes: - Preview-plugin activation: the PR test plugin patches /etc late (after rc.M started acpid/elogind with the stock config) and re-applies every boot, so the new ACPI handler + elogind power-key drop-in never took effect and "Do nothing" still shut the server down. generate-pr-plugin.sh now restarts acpid/elogind when the patch touches their files. (A real release bakes these into bzroot, so its boot ordering is already correct.) - Force tabbed rendering of Power Options (Tabs="true") so Power Mode and Power Button show as tabs instead of stacked sections. - Let the "no available power modes" notice grow (height:auto) so it no longer overflows and overlaps the Power Button heading at 390px. - Debounce duplicate power-button ACPI events so a doubled event is not logged (or acted on) twice.
Full Unraid releases extract the webgui etc tree under /usr/local, while PR test plugins overlay etc directly under /. Resolve both layouts into the runtime /etc paths before acpid and elogind start. Refs: https://linear.app/lime-technology/issue/DST-139/configurable-power-button-behavior-acpi-prevent-accidental-shutdowns
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
🔧 PR Test Plugin AvailableA test plugin has been generated for this PR that includes the modified files. Version: 📥 Installation Instructions:Install via Unraid Web UI:
Alternative: Direct Download
|
Summary
The 7.3 backport needs the Power Options UI and
rc.dintegration from PR #2671, but the ACPI handler files underetc/acpi/belong to a separate change; this PR now limits the backport to the requested scope.Why This Exists
Unraid 7.3 needs the Power Options UI and boot-service integration without duplicating the separately maintained ACPI dispatcher implementation. Keeping the boundaries explicit avoids two changes owning the same ACPI files.
Resolution
This PR retains the Power Options pages, power-button settings contract,
rc.dstartup integration, elogind policy, PR-plugin packaging support, and the runtime-path test helper. It deliberately removesetc/acpi/powerbutton.d/READMEandetc/acpi/unraid_power_handler.sh; the companion ACPI change remains outside this PR.Reviewer Considerations
etc/acpi/*implementation files are included in this branch.rc.dintegration against the separately supplied ACPI handler path; this PR does not own the dispatcher or action README.rc.powerbutton; it does not introduce production ACPI files.Behavior Changes
rc.dservices retain the power-button runtime setup and elogind policy integration.Implementation Summary
rc.acpid,rc.elogind, andrc.powerbuttonstartup integration.etc/acpi/from the backport.Verification
bash tests/power-button-runtime.sh— passed.bash -n etc/rc.d/rc.acpid etc/rc.d/rc.elogind etc/rc.d/rc.powerbutton— passed.PowerButton.page,PowerMode.page, andPowerModeCpu.page— passed before this scope-only deletion.git diff --check— passed.Risk
Medium; the PR intentionally does not provide the production ACPI dispatcher. QA must test the combined 7.3 result with the companion ACPI change and verify that the retained
rc.dintegration does not claim ownership of those files.Related to OS-644