Files
Nomarchy/pkgs/nomarchy-battery-notify/default.nix
Bernardo Magri fb78c814cc
All checks were successful
Check / eval (push) Successful in 3m4s
feat(battery): low-battery notifications at the bar's 25/10% thresholds (item 13 slice)
The bar colored the battery at 25/10% but nothing notified. New
shellcheck-gated watcher (pkgs/nomarchy-battery-notify, overlay) polls
the same sysfs the bar reads — type=Battery, scope!=Device — and fires
one toast per downward crossing (normal at 25%, critical at 10%; swaync
keeps critical up until dismissed), re-armed by charging. Self-gates on
battery presence (the powerprofile pattern), so desktops get a silent
no-op. HM user unit behind nomarchy.batteryNotify.enable (default on)
with libnotify on the unit PATH; notify-send resolves from PATH so the
VM check can shim it. poweralertd rejected: its UPower thresholds
(20/5) wouldn't match the bar, and it toasts every plug/unplug.

Verified: V0 (flake check, bash -n); V1 (template-home builds, unit in
the generation); V2 GREEN (new checks.battery-notify, test_power fake
battery: self-gate, silence at 80%, one toast per crossing, critical
urgency, charging re-arms). Remains: V3 — real swaync toast on a
draining laptop (HARDWARE-QUEUE).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-05 15:11:06 +01:00

13 lines
546 B
Nix

# Low-battery notification watcher (nomarchy.batteryNotify). A package
# (not an inline script) so the VM check can exercise the crossing logic
# on a minimal node against a test_power fake battery — same reasoning
# as nomarchy-doctor. libnotify is deliberately NOT a runtimeInput: the
# user unit puts it on PATH; the check shims notify-send instead.
{ writeShellApplication, coreutils }:
writeShellApplication {
name = "nomarchy-battery-notify";
runtimeInputs = [ coreutils ];
text = builtins.readFile ./nomarchy-battery-notify.sh;
}