Skip to content

feat(battery): support profile-based charge limit UI messages - #332

Open
JoJoStax wants to merge 1 commit into
wayle-rs:masterfrom
JoJoStax:ui-charge-threshold-profiles
Open

feat(battery): support profile-based charge limit UI messages#332
JoJoStax wants to merge 1 commit into
wayle-rs:masterfrom
JoJoStax:ui-charge-threshold-profiles

Conversation

@JoJoStax

Copy link
Copy Markdown

Objective

The battery dropdown currently assumes charge limits are strictly percentage-based numeric thresholds. However, certain laptops (like Lenovo IdeaPads and other brands) use sysfs profile-based charge limits (e.g., Long_Life vs Standard), which UPower abstracts. When these profile-based limits are active, the backend returns a threshold of 0, causing the UI to confusingly display "Limit to 0%".

Backend Context: This PR depends on wayle-services#38, which implements the fallback mechanism to detect and handle profile-based limits.

Solution

Updated BatterySection to handle 0 percentage limits as profile-based optimized limits rather than literal zero percent:

  • Added localization keys for English and French: dropdown-battery-charge-limit-optimized and dropdown-battery-charge-limit-optimized-subtitle
  • Updated wayle-shell/src/shell/bar/dropdowns/battery/battery_section/mod.rs to detect when model.charge_end_threshold == 0
  • Displays "Optimized Battery Health" with subtitle "Prolongs lifespan by limiting full charges" instead of "Limit to 0%"
  • Numeric percentage limits (e.g., 80) continue to display normally

Test Plan

  • Tested locally on a Lenovo laptop using charge_types (profile-based limits)
  • Verified UI displays the new localized strings when charge threshold is 0
  • Verified traditional numeric percentage limits still display correctly

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Charge-Limit Fallback to charge-types when numerical values aren't available.

1 participant