Show OSD when ACPI platform profile changes#5802
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an immediate on-screen display (OSD) via SwayOSD when the ACPI platform profile changes (e.g., ThinkPad performance-mode key), implemented as a user-level systemd service backed by a small Python sysfs watcher.
Changes:
- Add
omarchy-powerprofiles-osd-watch(Python) to watch/sys/firmware/acpi/platform_profileviaPOLLPRIand trigger an OSD. - Add a user systemd unit to run the watcher after
swayosd-server.service. - Add first-run and migration hooks intended to enable the service for new and existing installs.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
bin/omarchy-powerprofiles-osd-watch |
New watcher that polls the ACPI platform profile sysfs node and triggers SwayOSD. |
config/systemd/user/omarchy-powerprofiles-osd.service |
New user service unit to run the watcher alongside the graphical session and SwayOSD. |
install/first-run/powerprofiles-osd.sh |
Intended first-run enablement hook for fresh installs. |
migrations/1778646038.sh |
Migration to install the unit file and enable the service for existing users. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1 @@ | |||
| systemctl --user enable --now omarchy-powerprofiles-osd.service | |||
There was a problem hiding this comment.
Good catch — fixed in c79d8f3 by adding the script to the explicit enumeration in bin/omarchy-first-run right after swayosd.sh.
The ThinkPad mode key (and any other hardware/userspace path that flips the ACPI platform profile) now produces a SwayOSD with the new profile name and a freedesktop power-profile icon, mirroring how volume and brightness changes already surface to the user. The watcher reads /sys/firmware/acpi/platform_profile and uses POLLPRI to react to firmware-driven changes. This deliberately bypasses power-profiles-daemon's PropertiesChanged signal, which is gated behind GLib's GFileMonitor "changes-done-hint" event and therefore arrives ~2 seconds after the firmware updated the file. POLLPRI fires as soon as the kernel sees the value change, so the OSD is effectively instantaneous.
bin/omarchy-first-run enumerates first-run scripts explicitly, so adding install/first-run/powerprofiles-osd.sh alone never runs on fresh installs. Invoke it right after the SwayOSD setup.
c79d8f3 to
5fc30e2
Compare
Summary
omarchy-powerprofiles-osd-watch(Python, stdlib only) +omarchy-powerprofiles-osd.service, plus a first-run hook for new installs and a migration to enable it for existing users.Why POLLPRI instead of listening to
power-profiles-daemon?I initially listened to
net.hadess.PowerProfilesPropertiesChanged. That works but the OSD consistently lagged ~2 seconds behind the actual hardware change. Diagnosing it with three parallel detectors:power-profiles-daemonuses GLib'sGFileMonitoron/sys/firmware/acpi/platform_profile, and GLib coalesceschangedevents with a fixed ~2s window before firingchanges-done-hint. The daemon only emits the DBus signal at the end of that window. Watching the sysfs file directly withPOLLPRIreacts to the kernel's notification immediately.Files
bin/omarchy-powerprofiles-osd-watch— Python stdlib watcher (select.poll()+POLLPRIon the sysfs node).config/systemd/user/omarchy-powerprofiles-osd.service—Type=simple, ordered afterswayosd-server.service.install/first-run/powerprofiles-osd.sh— enables the service on new installs.migrations/1778646038.sh— installs the unit file and enables the service for existing users.Notes
/sys/firmware/acpi/platform_profile. If the node is absent the watcher exits cleanly and the service goes inactive — no impact on unsupported hardware.amd_pstate); the visible OSD latency went from ~2 s to effectively instant on mode-key press.power-profile-*-symbolicnames that current icon themes already ship.Test plan
install/first-run/powerprofiles-osd.shenables the service, mode key shows the OSD.omarchy update: migration1778646038.shenables the service.powerprofilesctl set performance|balanced|power-saveralso produces an OSD./sys/firmware/acpi/platform_profile, the service exits cleanly.🤖 Generated with Claude Code