Skip to content

feat(power): backport configurable power-button controls to 7.3 - #2715

Draft
Eli Bosley (elibosley) wants to merge 7 commits into
7.3from
feature/os-644-backport-power-button-7.3
Draft

feat(power): backport configurable power-button controls to 7.3#2715
Eli Bosley (elibosley) wants to merge 7 commits into
7.3from
feature/os-644-backport-power-button-7.3

Conversation

@elibosley

@elibosley Eli Bosley (elibosley) commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

The 7.3 backport needs the Power Options UI and rc.d integration from PR #2671, but the ACPI handler files under etc/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.d startup integration, elogind policy, PR-plugin packaging support, and the runtime-path test helper. It deliberately removes etc/acpi/powerbutton.d/README and etc/acpi/unraid_power_handler.sh; the companion ACPI change remains outside this PR.

Reviewer Considerations

  • Confirm that no etc/acpi/* implementation files are included in this branch.
  • Review the rc.d integration against the separately supplied ACPI handler path; this PR does not own the dispatcher or action README.
  • The runtime-path test uses temporary fixture files to validate rc.powerbutton; it does not introduce production ACPI files.
  • The PR remains draft pending review and companion-change coordination.

Behavior Changes

  • Settings > Power Options exposes Power Mode and Power Button as tabs.
  • The 7.3 rc.d services retain the power-button runtime setup and elogind policy integration.
  • The ACPI dispatcher implementation is intentionally not changed by this PR.

Implementation Summary

  • Split Power Mode CPU and Power Button settings pages and add the power-button action hook.
  • Retain rc.acpid, rc.elogind, and rc.powerbutton startup integration.
  • Retain PR-plugin packaging support and the fixture-based runtime-path test.
  • Remove the two production files under 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.
  • PHP lint for PowerButton.page, PowerMode.page, and PowerModeCpu.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.d integration does not claim ownership of those files.

Related to OS-644

Eli Bosley (elibosley) and others added 6 commits August 10, 2026 12:50
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
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a79125de-8d6b-4c10-b848-81fbf17bb0ec

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

🔧 PR Test Plugin Available

A test plugin has been generated for this PR that includes the modified files.

Version: 2026.08.10.1726
Build: View Workflow Run

📥 Installation Instructions:

Install via Unraid Web UI:

  1. Go to Plugins → Install Plugin
  2. Copy and paste this URL:
https://preview.dl.unraid.net/pr-plugins/pr-2715/webgui-pr-2715.plg
  1. Click Install

Alternative: Direct Download

⚠️ Important Notes:

  • Testing only: This plugin is for testing PR changes
  • Backup included: Original files are automatically backed up
  • Easy removal: Files are restored when plugin is removed
  • Conflicts: Remove this plugin before installing production updates
  • Post-merge behavior: This preview stays available after merge until preview storage expires or it is manually cleaned up

📝 Modified Files:

Click to expand file list
emhttp/languages/en_US/helptext.txt
emhttp/plugins/dynamix/PowerButton.page
emhttp/plugins/dynamix/PowerMode.page
emhttp/plugins/dynamix/PowerModeCpu.page
etc/elogind/logind.conf.d/20-unraid-powerbutton.conf
etc/rc.d/rc.acpid
etc/rc.d/rc.elogind
etc/rc.d/rc.powerbutton

🔄 To Remove:

Navigate to Plugins → Installed Plugins and remove webgui-pr-2715, or run:

plugin remove webgui-pr-2715

🤖 This comment is automatically generated and will be updated with each new push to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant