4 releases (2 breaking)
new 0.7.0 | Apr 27, 2025 |
---|---|
0.6.1 | Mar 16, 2025 |
0.6.0 | Mar 8, 2025 |
0.5.0 | Feb 18, 2025 |
#767 in Command line utilities
53KB
861 lines
battered
Make the most of your laptop's battery life with custom actions and informative desktop notifications.
For example, it could send a notification to call attention to the battery discharging, call a script to start battery saving mode on crossing the next threshold, and send another - persistent - notification when the battery level gets critical.
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
:
battered
📦 Installation
battered
is available on crates.io and can be installed from there:
cargo install battered
If you're using Arch Linux you can also install it from the AUR, using your favorite AUR helper (e.g. paru
):
paru -Syu battered
⚙️ 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.toml
if$HOME
is 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 |
Example config:
interval = 60 # Battery level check interval in seconds; optional; defaults to 120; integer
[[action]]
percentage = 0.25 # Run action below this threshold; required; decimal
command = "./powersave.sh enable" # CLI command to run; optional; string
[action.notify] # Notification settings; optional; table
summary = "Battery low!" # Notification summary; required within action.notify table; string
body = "Battery below $percentage%!" # Notification body; optional; string
urgency = "Critical" # Notfication urgency; optional; defaults to `Normal`; enum[ Low | Normal | Critical ]
icon = "battery-caution" # Notification icon; optional; defaults to "battery-discharging"; string
timeout = 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
[[action]]
percentage = 0.95
[action.notify]
summary = "Battery discharging"
# Special action to run once connected to AC
# Options are the same as for regular actions
[on_ac]
percentage = 0.10 # Only run if battery level above this threshold; optional; decimal
command = "./powersave.sh disable"
[on_ac.notify]
summary = "Battery charging"
urgency = "Low"
icon = "battery-good-charging"
timeout = 300
📋 Logging
Logging is configured via the RUST_LOG
env variable. The provided systemd unit example sets the log level to WARN
per default.
📜 License
battered
is distributed under the terms of the MIT license.
Dependencies
~3–29MB
~421K SLoC