Skip to content

DrogLing/battery-cap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Battery Cap

A KDE Plasma 6 system-tray plasmoid that emulates a freely adjustable battery charge threshold (e.g. 80 %) on Lenovo Ideapad/Yoga laptops.

Download from the KDE Store

Screenshots

Popup with the charge-threshold slider    Tray icon with the target-% pill

Why?

Many Lenovo models expose only a binary conservation mode on Linux: charge to 100 % or a fixed hardware cap (typically ~60 %, on some models ~80 %) — nothing in between. The standard Linux interface for arbitrary limits (charge_control_end_threshold) is missing on these models.

Battery Cap watches the charge level and toggles the conservation mode dynamically with hysteresis, producing any target threshold you like. On AC power the battery then oscillates between target − hysteresis and target (default: 75–80 %).

Existing tools (CLI scripts, GNOME extension, PlasmaVantage) can only switch conservation mode on/off — the dynamic emulation of an arbitrary threshold is what sets this project apart.

How it works

State machine (only active while the AC adapter is connected):

Condition Action
charge ≥ target conservation mode on (stop)
charge ≤ target − hysteresis conservation mode off (charge)
in between hold current state (dead band)

For targets near the hardware cap, conservation mode effectively stays on all the time. Everything runs inside the plasmoid (plasmashell) — no separate daemon.

Requirements

  • KDE Plasma 6, kpackagetool6
  • Lenovo Ideapad/Yoga with the ideapad_acpi driver and /sys/bus/platform/devices/VPC2004:*/conservation_mode
  • Write access to conservation_mode (see the udev rule below)

Installation

1. udev rule (once, with sudo)

So the plasmoid can toggle without a password prompt, conservation_mode must be writable:

sudo cp udev/99-ideapad-conservation.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger --subsystem-match=platform
# or simply reboot

Verify:

ls -l /sys/bus/platform/devices/VPC2004:*/conservation_mode   # -rw-rw-rw-

2. Install the plasmoid

From the KDE Store (easiest): right-click the panel → Add WidgetsGet New WidgetsDownload New Plasma Widgets, then search for "Battery Cap". Store page: https://store.kde.org/p/2364355

Or manually from source:

./install.sh

Then enable "Battery Cap" via System Tray → Configure → Entries.

Usage

Click the tray icon to open a popup with:

  • current charge level & status
  • a switch to enable/disable the dynamic threshold
  • a slider for the target threshold (50–100 %)
  • a Charge fully once switch (travel mode): charges to 100 % now and automatically restores the threshold once you unplug
  • power-supply and conservation-mode status

Fine-tuning via right-click → Configure Battery Cap…:

  • hysteresis and poll interval
  • an advanced mode with explicit stop/start thresholds instead of the target + hysteresis pair

If the device is unsupported or conservation_mode is not writable, the popup shows a diagnostic hint.

Development / testing

./install.sh test        # install/upgrade and launch plasmawindowed

Watch the conservation mode change live:

watch -n2 cat /sys/bus/platform/devices/VPC2004:*/conservation_mode

Portability

All device paths are resolved via globs in the helper script (package/contents/code/battery-cap-helper.sh): BAT*, ADP*/AC*, and VPC2004:* with a generic */conservation_mode fallback — so the plasmoid should work on other Ideapad/Yoga models that use the same mechanism.

Uninstall

./install.sh remove

License

GPL-3.0+

About

Freely adjustable battery charge threshold for Lenovo Ideapad/Yoga — a KDE Plasma 6 tray plasmoid (emulated via conservation mode)

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors