#battery #notifications #cli-command #linux #command #cli

app battered

Regularly polls battery levels and sends notifications on crossing certain thresholds

3 unstable releases

new 0.6.1 Mar 16, 2025
0.6.0 Mar 8, 2025
0.5.0 Feb 18, 2025

#3 in #notification

Download history 28/week @ 2025-02-12 76/week @ 2025-02-19 12/week @ 2025-02-26 130/week @ 2025-03-05 132/week @ 2025-03-12

378 downloads per month

MIT license

46KB
713 lines

battered

crates.io

battered Icon

Regularly polls battery levels and reacts to crossing configurable thresholds.

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

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

Configuration

battered looks for a configuration file in the following places:

  1. $XDG_CONFIG_HOME/battered/config.toml
  2. $HOME/.config/battered/config.toml
  3. /.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

Logging

Logging is configured via the RUST_LOG env variable. The provided systemd unit example sets the log level to WARN per default.

Dependencies

~3–29MB
~407K SLoC