feat(battery): low-battery notifications at the bar's 25/10% thresholds (item 13 slice)
All checks were successful
Check / eval (push) Successful in 3m4s
All checks were successful
Check / eval (push) Successful in 3m4s
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>
This commit is contained in:
29
modules/home/battery-notify.nix
Normal file
29
modules/home/battery-notify.nix
Normal file
@@ -0,0 +1,29 @@
|
||||
# Low-battery notifications (nomarchy.batteryNotify) — the bar colors the
|
||||
# battery @warn/@bad at 25/10% (waybar.nix battery.states) but nothing
|
||||
# *notified*; this watcher fires a toast at those same thresholds. Session-
|
||||
# side and self-gating on a battery being present (the powerprofile-script
|
||||
# pattern — no system→home coupling), so it's a silent no-op on desktops.
|
||||
# swaync shows critical toasts until dismissed (timeout-critical = 0), so
|
||||
# the 10% one can't slip by unseen. Logic lives in pkgs/nomarchy-battery-
|
||||
# notify (overlay), where checks.battery-notify exercises it.
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
config = lib.mkIf config.nomarchy.batteryNotify.enable {
|
||||
systemd.user.services.nomarchy-battery-notify = {
|
||||
Unit = {
|
||||
Description = "Low-battery notifications (25/10%, the bar's thresholds)";
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
After = [ "graphical-session.target" ];
|
||||
};
|
||||
Service = {
|
||||
# The script resolves notify-send from PATH (that's what the VM
|
||||
# check shims); here libnotify provides the real one.
|
||||
Environment = "PATH=${lib.makeBinPath [ pkgs.libnotify ]}";
|
||||
ExecStart = "${pkgs.nomarchy-battery-notify}/bin/nomarchy-battery-notify";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
Install.WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -26,6 +26,7 @@
|
||||
./viewers.nix # zathura (Stylix-themed) + imv — PDF/image viewing
|
||||
./mime.nix # default applications (mimeapps.list), degrades with the suite
|
||||
./recording.nix # nomarchy-record: screen recording behind Capture + the bar ⏺
|
||||
./battery-notify.nix # low-battery toasts at the bar's 25/10% thresholds
|
||||
];
|
||||
|
||||
# Clipboard history (wl-paste watcher); browsed via the SUPER+CTRL+V
|
||||
|
||||
@@ -242,6 +242,7 @@ in
|
||||
waybar.enable = lib.mkEnableOption "Nomarchy's Waybar configuration" // { default = true; };
|
||||
rofi.enable = lib.mkEnableOption "Nomarchy's themed rofi launcher + the nomarchy-menu dispatcher" // { default = true; };
|
||||
swaync.enable = lib.mkEnableOption "swaync notifications, themed from the state file" // { default = true; };
|
||||
batteryNotify.enable = lib.mkEnableOption "low-battery notifications at the bar's thresholds (25% low, 10% critical — that one stays up until dismissed); self-gating, a silent no-op on machines without a battery" // { default = true; };
|
||||
idle.enable = lib.mkEnableOption "hyprlock + hypridle (idle lock, display off, suspend)" // { default = true; };
|
||||
yazi.enable = lib.mkEnableOption "the yazi TUI file manager, themed with a curated plugin set" // { default = true; };
|
||||
osd.enable = lib.mkEnableOption "swayosd on-screen display for volume/brightness/mute" // { default = true; };
|
||||
|
||||
Reference in New Issue
Block a user