a battery monitor daemon. listens to upower events over dbus and fires configurable commands.
go install github.com/yaaaarn/tangle@latest
add to your flake.nix inputs:
tangle = {
url = "github:yaaaarn/tangle";
inputs.nixpkgs.follows = "nixpkgs";
};then add tangle.packages.${system}.default to your environment.systemPackages or home-manager packages.
tangle
looks for a config.yaml in the current directory, ~/.config/tangle/config.yaml, /etc/tangle/config.yaml, or /var/lib/tangle/config.yaml.
actions:
- trigger_on_state: "Discharging"
threshold_percentage: 20
operator: "<="
command:
- notify-send
- "--urgency=normal"
- "--icon=battery-low"
- "battery low ({percent}%)"| field | description |
|---|---|
trigger_on_state |
Charging, Discharging, Full |
threshold_percentage |
percentage to compare against |
operator |
any, ==, <=, >= |
command |
command + args to execute ({percent} and {state} are substituted) |
{
imports = [ tangle.nixosModules.default ];
services.tangle = {
enable = true;
actions = [
{
trigger_on_state = "Discharging";
threshold_percentage = 20;
operator = "<=";
command = [
"notify-send"
"--urgency=normal"
"--icon=battery-low"
"battery low ({percent}%)"
];
}
];
};
}a home-manager module is also available:
tangle.hmModules.default.
# enter the dev shell (if using nix)
nix develop
# build
go build .mit