Feat/battery threshold (#7)
* feat(battery-threshold): add translations and rule file * feat(battery-threshold): add setup script * feat(battery-threshold): add plugin manifest * feat(battery-threshold): implement battery-threshold service * feat(battery-threshold): implement battery-threshold widget * feat(battery-threshold): implement battery-threshold panel * feat(battery-threshold): add readme * chore(battery-threshold): add dependencies field * chore(battery-threshold): add thumbnail * docs(battery-threshold): add thumbnail to readme * fix(battery-threshold): add thumbnail from generator * chore(battery-threshold): add license and icon fields to plugin.toml * style(battery-threshold): replace tabs with spaces * style(battery-threshold): unflatten translation files * refactor(battery-threshold): use translations for widget tooltip * chore(battery-threshold): replace raw strings with translations * chore(battery-threshold): remove panel ipc event * chore(battery-threshold): check error on file read * chore(battery-threshold): remove `setUpdateInterval` calls * style(battery-threshold): fix formatting * chore(battery-threshold): remove tags capital letters * Update plugin.toml * chore(battery-threshold): remove de fr and tr translations * chore(battery-threshold): update thumbnail * fix(battery-threshold): add shell quoting for runAsync * chore(battery-threshold): embed rule file content in setup script * chore(battery-threshold): update manifest * refactor(battery-threshold): use noctalia.pluginDataDir, log read/write errors * docs(battery-threshold): update README to match template * chore(battery-threshold): add missing dependencies to manifest --------- Co-authored-by: Lemmy <studio@quadbyte.net>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
# 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
|
||||
|
||||
- `polkit` - required for interactive setup
|
||||
- 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`, `pkexec`,
|
||||
`bash`, `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
|
||||
directory and restored across reboots.
|
||||
Reference in New Issue
Block a user