Skip to content

feat(power): lower refresh rate on battery - #2428

Merged
bbedward merged 12 commits into
duxlabs-dev:masterfrom
atimofeev:master
Jul 17, 2026
Merged

bbedward merged 12 commits into
duxlabs-dev:masterfrom
atimofeev:master

Conversation

@atimofeev

@atimofeev atimofeev commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Add a Power & Sleep setting that lowers eligible displays to 60 Hz on battery and restores their previous mode on AC power.

Skip displays without an available 60 Hz mode, displays with a single refresh-rate option, current modes at or below 60 Hz, and VRR-enabled outputs.

Apply niri changes at runtime through output commands and use wlr-output-management as fallback.

Closes #1203

@atimofeev
atimofeev marked this pull request as draft May 15, 2026 21:16
@atimofeev

Copy link
Copy Markdown
Contributor Author

Need help with additional testing, as I only have a single device with multiple refresh rates display (240/60).

Also, changes to DisplayService.qml might be overengineered.

@atimofeev atimofeev changed the title feat(power): lower refresh rate on battery (#1203) feat(power): lower refresh rate on battery May 15, 2026
@atimofeev

Copy link
Copy Markdown
Contributor Author

Here's the first issue:

  • When you restart dms being on battery, it thinks that configured refresh rate is 60hz and it never goes back to the preferred 240hz

Probably can be resolved with this logic:

  • Get active monitor profile refresh rate and use it as baseline
  • If monitor profiles are not configured, fall back to monitor preferred refresh rate
  • Re-check these steps on profile or power source change

@atimofeev

atimofeev commented May 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Implemented stateless transitions between 60hz and higher refresh rates.
Also improved logging to be more human-readable.

@atimofeev

Copy link
Copy Markdown
Contributor Author

update after latest changes: functionality looks better, but I’m still hitting one nasty crash.

I can reproduce with this flow:
plug AC -> connect external display over type-c dp -> quickshell crashes

dumps end in same path:
Qt::endPropertyUpdateGroup -> WindowsetManager::onServerCommit -> WorkspaceManager::ext_workspace_manager_v1_done (SIGSEGV)

so this looks more like quickshell workspace/output commit race on hotplug/reconfigure.
refresh-rate logic still seems to be trigger surface (mode apply happens right before crash), but probably not root cause by itself.

@atimofeev

atimofeev commented May 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Resolved.

Added minimal 300ms debounce around DisplayService refresh-rate sync, and BatteryService now routes startup/power/profile/output refresh triggers through requestSync(...). This coalesces AC + external-display event bursts and avoids repeated mode applies that were triggering quickshell crash.

@atimofeev
atimofeev marked this pull request as ready for review June 17, 2026 21:25
@Spoch-dev

This comment was marked as spam.

@atimofeev

Copy link
Copy Markdown
Contributor Author

Although I'm no longer daily-driving Hyprland, this feature seems to work there after a quick test.

Add a Power & Sleep setting that lowers eligible displays to 60 Hz on battery and restores their previous mode on AC power.

Skip displays without an available 60 Hz mode, displays with a single refresh-rate option, current modes at or below 60 Hz, and VRR-enabled outputs.
Apply niri changes at runtime through output commands and use wlr-output-management as fallback.
Comment thread quickshell/Services/DisplayService.qml Resolved
Comment thread quickshell/Services/DisplayService.qml Resolved
Comment thread quickshell/Services/DisplayService.qml Resolved
Comment thread quickshell/Services/BatteryService.qml Resolved
Comment thread quickshell/Common/SettingsData.qml Resolved
Comment thread quickshell/Services/DisplayService.qml Resolved
@atimofeev
atimofeev requested a review from bbedward July 16, 2026 23:10
@bbedward
bbedward merged commit adbbd9b into duxlabs-dev:master Jul 17, 2026
1 check passed
marcusramberg pushed a commit to marcusramberg/DankMaterialShell that referenced this pull request Sep 2, 2026
* feat(power): lower refresh rate on battery (duxlabs-dev#1203)

Add a Power & Sleep setting that lowers eligible displays to 60 Hz on battery and restores their previous mode on AC power.

Skip displays without an available 60 Hz mode, displays with a single refresh-rate option, current modes at or below 60 Hz, and VRR-enabled outputs.
Apply niri changes at runtime through output commands and use wlr-output-management as fallback.

* fix(quickshell): debounce display refresh sync

* chore: regenerate settings_search_index.json for pre-commit CI fix

* fix: translator context is missing for lowerDisplayRefreshRateOnBattery

* fix: activeDisplayProfileModes is missing from SettingsSpec

* feat: added guard to syncRefreshRates function

* refactor(display): move refresh sync listeners to display service

* fix(display): publish active profile modes after config write

* feat(display): persist previous refresh modes

* fix(display): route refresh mode writes through compositor backends

* fix(display): detect preferred niri refresh modes

* some small cleanups

---------

Co-authored-by: bbedward <[email protected]>
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.

Refresh rate change on power source

3 participants