Skip to content

feat(bar): add battery charge limit toggle button - #1908

Open
Swastik36 wants to merge 23 commits into
caelestia-dots:mainfrom
Swastik36:feat/battery-charge-limit
Open

Swastik36 wants to merge 23 commits into
caelestia-dots:mainfrom
Swastik36:feat/battery-charge-limit

Conversation

@Swastik36

@Swastik36 Swastik36 commented Aug 28, 2026

Copy link
Copy Markdown

Summary

Adds battery charge threshold & conservation mode control to the battery popout with multi-vendor sysfs detection.

Changes

  • Hardware detection: Automatically detects vendor sysfs interfaces for Lenovo IdeaPad/Legion (ideapad_acpi), ASUS, Huawei, LG, Samsung, Apple Silicon (Asahi), and standard Linux kernel charge_control_end_threshold.
  • BIOS lock handling: Detects read-only sysfs nodes when locked in BIOS/UEFI, disabling the control with a tooltip instead of silently failing.
  • Safety: Validates sysfs paths and snaps target values to nearest hardware-supported tiers.
  • i18n: Converted to Tr.tr translation system.

Preview

Inactive (100% Charge) Active (Capped at 60%)
swappy-20260831_203107 swappy-20260831_203246

@Swastik36
Swastik36 requested a review from a team August 28, 2026 15:35
@Swastik36 Swastik36 changed the title feat(bar/battery): add battery charge limit toggle button feat(bar): add battery charge limit toggle button Aug 28, 2026
@sufficientpast

Copy link
Copy Markdown
Contributor

#1667 covers it with a better implementation imo

@Swastik36

Swastik36 commented Aug 29, 2026

Copy link
Copy Markdown
Author

#1667 covers it with a better implementation imo

You've got it wrong. Although a power panel in the nexus is i think very much required, my implementation is for a completely different thing. #1667 allows us to make battery warning while mine is specifically for devices with battery. Manufactures make a conservation mode locking the battery percentage and making it use the power straight up from the source, this PR and #1667 serve two completely different purposes and can coexist.
Mine is for the popout in the taskbar
Here is a video recording
https://github.com/user-attachments/assets/7a586db9-eddd-4c52-bbf0-a2d30e336f5f

#1667 configures desktop notifications and caelestia, this PR controls hardware battery
health & charging thresholds.
@sufficientpast

@Swastik36
Swastik36 force-pushed the feat/battery-charge-limit branch from 430084a to 62e2e98 Compare August 29, 2026 06:34
@sufficientpast

sufficientpast commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

oh i thought 1667 already had the threshold option mb
also when you enable the lock from bios menu
image
it becomes untogglable
i still think nexus is a better place for it and coexisting with 1667 would be best as you said

@Swastik36
Swastik36 force-pushed the feat/battery-charge-limit branch 8 times, most recently from 24afa1a to 89970a0 Compare August 29, 2026 13:42
Swastik36 added a commit to Swastik36/shell that referenced this pull request Aug 31, 2026
@Swastik36
Swastik36 force-pushed the feat/battery-charge-limit branch 2 times, most recently from 1867012 to a818bf5 Compare September 1, 2026 13:13
@dxnnv dxnnv added the enhancement New feature or request label Sep 3, 2026
@Swastik36
Swastik36 force-pushed the feat/battery-charge-limit branch from a818bf5 to 305caec Compare September 3, 2026 13:34
@Chujo58

Chujo58 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

I quite like the idea, but I'm wondering also on how many devices this would work. I had to fix this in my BIOS directly. But this is imo very cool

@Swastik36
Swastik36 force-pushed the feat/battery-charge-limit branch 2 times, most recently from 054f16a to d055509 Compare September 12, 2026 05:52
Swastik36 and others added 15 commits September 16, 2026 21:29
…odernize translations

* feat(services): dynamic sysfs detection for Lenovo IdeaPad, Asus, LG, Samsung, Apple Silicon, and generic power supply
  - Scan /sys/bus/platform/drivers/ideapad_acpi/*/conservation_mode dynamically via QDir globbing, including VPC2004:00/01 platform devices
  - Add support for Samsung battery_life_extender (80% cap) and Apple Silicon macsmc-battery
  - Add generic fallback for /sys/class/power_supply/*/charge_control_end_threshold and legacy charge_stop_threshold
  - Drop incompatible legacy huawei-wmi path that expects space-separated string pairs in favor of standard kernel power_supply loop

* feat(services): detect read-only sysfs and BIOS threshold locks
  - Check sysfs write permissions and expose isReadOnly property to QML
  - Guard writeValue, toggle, and setThreshold against read-only sysfs nodes
  - Disable QML controls and show "Locked in BIOS (%1%)" with descriptive tooltip when locked

* fix(services): robust threshold handling and dynamic notifications
  - Snap off-tier threshold requests to closest tier via std::ranges::min_element
  - Map binary conservation threshold calls to target cap boundary (<= 60% enable, 100% disable)
  - Replace CONSTANT with NOTIFY controlTypeChanged on hardware capability properties
  - Gracefully format subtitle as "Limit disabled" when threshold reads 0

* feat(bar/i18n): modernize Battery.qml to Caelestia.I18n Tr framework
  - Replace all qsTr usages with Tr.tr, Tr.trCtx, and Tr.trN
  - Remove empty unsupportedCard to avoid placeholder clutter on desktop systems
@Swastik36
Swastik36 force-pushed the feat/battery-charge-limit branch from 2d8d24a to 9f5964c Compare September 16, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants