battered
Make the most of your laptop's battery life with custom actions and informative desktop notifications.
Written in Rust, battered uses minimal system resources.
Table of Contents
Features
- Unlimited custom actions
- Customizable desktop notifications with placeholder values
- Optional action and notification on connecting power supply
- Configurable poll interval
Usage
First, make sure you've configured some actions. Then simply run battered:
Installation
battered is available on crates.io and can be installed from there:
If you're using Arch Linux you can also install it from the AUR using your favorite AUR helper (e.g. paru):
Configuration
battered looks for a configuration file in the following places:
$XDG_CONFIG_HOME/battered/config.toml$HOME/.config/battered/config.toml/.config/battered/config.tomlif$HOMEis not set
The summary and body fields of the [action.notify] table support optional placeholders which will be replaced with calculated values. The following placeholders are available:
| Placeholder | Description |
|---|---|
$percentage |
Current battery level in percent |
By default battered will monitor the first battery it finds. Use the serial_number config value to pick a specific battery instead.
One way to find the serial number is through sysfs. E.g. find the serial number of BAT0:
Example config:
= 60 # Battery level check interval in seconds; optional; defaults to 120; integer
= "31415" # Serial number of battery; optional; defaults to first battery; string
[[]]
= 0.25 # Run action below this threshold; required; decimal
= "./powersave.sh enable" # CLI command to run; optional; string
[] # Notification settings; optional; table
= "Battery low!" # Notification summary; required within action.notify table; string
= "Battery below $percentage%!" # Notification body; optional; string
= "Critical" # Notfication urgency; optional; defaults to `Normal`; enum[ Low | Normal | Critical ]
= "battery-caution" # Notification icon; optional; defaults to "battery-discharging"; string
= 0 # Notification timeout in ms; optional; defaults to desktop default; integer; `0` means no timeout
# There can be as many `action` entries as desired, and order doesn't matter
[[]]
= 0.95
[]
= "Battery discharging"
# Special action to run after connecting to AC
# Options are the same as for regular actions
[]
= 0.10 # Only run if battery level above this threshold; optional; decimal
= "./powersave.sh disable"
[]
= "Battery charging"
= "Low"
= "battery-good-charging"
= 300
Logging
Logging is configured via the RUST_LOG env variable. The provided systemd unit example sets the log level to WARN by default.
License
battered is distributed under the terms of the MIT license.