Files
community-plugins/battery-threshold/README.md
T
Damian D'SouzaandGitHub 253668025d Fix/battery threshold setup (#136)
* refactor(battery-threshold): change setup to run script in terminal via sudo

* chore(battery-threshold): update dependencies

* docs(battery-threshold): update threshold.txt location description

* chore(battery-threshold): bump version
2026-07-28 21:12:15 -04:00

62 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Battery Threshold Control
Control the battery charge threshold on laptop batteries to help extend overall
battery lifespan. Someone would use this plugin to limit maximum charge levels
while plugged in, reducing battery wear and heat.
## Plugin
| Field | Value |
| ------- | ------------------------------------------------------------------- |
| ID | `damian-ds7/battery-threshold` |
| Entries | Bar widget: `battery-threshold`; panel: `panel`; service: `service` |
## Requirements
- Laptop hardware supporting battery charge threshold control in sysfs
(`/sys/class/power_supply/*/charge_control_end_threshold`).
- The following external programs must be available on `PATH`: `test`, `sudo`,
`bash`, `readlink`, `cat`, `getent`, `groupadd`, `usermod`, `udevadm`, `chgrp`, and `chmod`.
## Usage
- **Bar Widget (`battery-threshold`)**: Displays the current battery threshold
in the bar. Click to toggle the panel.
- **Panel (`panel`)**: Adjust the battery threshold using a slider (40–100%).
Includes a **Configure Permissions** button if write access is missing. Toggle
the panel using:
```sh
noctalia msg panel-toggle damian-ds7/battery-threshold:panel
```
## Settings
| Setting | Type | Default | Description |
| ------------------ | -------- | ------------------------------ | ---------------------------------------------- |
| `battery_device` | `folder` | `/sys/class/power_supply/BAT0` | Path to the battery sysfs directory. |
| `charge_threshold` | `int` | `80` | Default charge threshold percentage (40–100%). |
## IPC
```sh
# Set charge threshold percentage (between 40 and 100)
noctalia msg plugin damian-ds7/battery-threshold:service all set 80
# Trigger setup script for udev permissions
noctalia msg plugin damian-ds7/battery-threshold:service all setup
```
## Notes
- **Permissions & Setup**: Requires write access to
`/sys/class/power_supply/BAT0/charge_control_end_threshold`. Automated setup
creates the `battery_ctl` group, adds the active user to it, and installs
`99-battery-threshold.rules` to `/etc/udev/rules.d/`.
- **Relogin / Reboot**: A logout or system reboot is required after running
setup for `battery_ctl` group membership changes to take effect.
- **Manual Setup Fallback**: If Polkit is not available, run
`sudo ./setup_rules.sh` manually from the plugin directory.
- **Persistence**: Threshold settings are stored in `threshold.txt` in plugin
data directory and restored across reboots.