Update Battery widget plugin (#311)

* fix: invalid check in getWarningThreshold

* fix: invalid status

* feat: use dbus events instead of polling

* fix: invalid status again

* fix: dump version and set valid plugin API

* fix: add commandExists check

* fix: getColor function (warning color when not charging)

* feat: use upower instead of cat /sys

* feat: notify on error

* fix: cleaner code

* fix: use noctalia.tr for notification (not logs, intended)

* feat: migrate from dbus-monitor to gdbus (everything in one line)

* feat: use gdbus to init and update, parse only when needed

* feat: add label_content and optimisations

* fix: remove multiple commands check not needed anymore

* fix: update README and dump version

* fix: default data, warning_threshold check, floor percent
This commit is contained in:
Yocraft-2000
2026-08-12 09:37:30 -04:00
committed by GitHub
parent 97389b0ff8
commit e9121c114c
4 changed files with 197 additions and 57 deletions
+5 -1
View File
@@ -9,6 +9,10 @@ Desktop/lockscreen widget that displays the current battery level and charging s
| ID | `yocraft/battery-widget` |
| Entries | Desktop widget: `widget` |
## Requirements
The plugin requires `gdbus` on `PATH` and `upower`.
## Usage
Add it to your desktop/lockscreen widgets using the widget editor. You can configure it in the widget settings.
@@ -20,6 +24,7 @@ Add it to your desktop/lockscreen widgets using the widget editor. You can confi
| `layout` | `select` | `horizontal` | Layout of the widget. |
| `show_glyph` | `bool` | `true` | Show the battery icon. |
| `show_label` | `bool` | `true` | Show text next to the icon. |
| `label_content` | `select` | `percent` | What the battery label shows: charge percentage, time remaining, or power draw. |
| `hide_plugged` | `bool` | `false` | Hide the battery widget when connected to AC power. |
| `hide_full` | `bool` | `false` | Hide the battery widget when fully charged. |
| `color` | `color` | `on_surface` | Color role for this widget's icon and label; fixed hex colors are also supported. |
@@ -27,7 +32,6 @@ Add it to your desktop/lockscreen widgets using the widget editor. You can confi
| `charging_color` | `color` | `on_surface` | Color applied when connected to AC power. |
| `battery` | `select` | `auto` | Detect the battery automatically or set a custom name. |
| `battery_name` | `string` | `BAT0` | Set a custom name for the battery. |
| `refresh_interval` | `int` | `60` | Controls how frequently the widget updates its content. (in seconds) |
## Notes