From d7a8f408b552b52e0c0f683c8b295a0cf72e7078 Mon Sep 17 00:00:00 2001 From: Breadway Date: Tue, 16 Jun 2026 17:07:20 +0800 Subject: [PATCH] Ship a low-battery-warning bread module by default A zero-config bread module (auto-discovered) that fires a critical notification once when the battery runs low and resets on AC. No-op on desktops. Demonstrates the bread automation layer out of the box. Co-Authored-By: Claude Opus 4.8 --- .../bread/modules/low-battery-warning.lua | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 iso/airootfs/etc/skel/.config/bread/modules/low-battery-warning.lua diff --git a/iso/airootfs/etc/skel/.config/bread/modules/low-battery-warning.lua b/iso/airootfs/etc/skel/.config/bread/modules/low-battery-warning.lua new file mode 100644 index 0000000..40b515b --- /dev/null +++ b/iso/airootfs/etc/skel/.config/bread/modules/low-battery-warning.lua @@ -0,0 +1,26 @@ +-- low-battery-warning — notify once when the battery runs low (zero-config). +-- Shipped active in BOS; auto-discovered by breadd. Safe on desktops too +-- (simply never fires without a battery). + +local M = bread.module({ name = "low-battery-warning", version = "1.0.0" }) + +local warned = false + +function M.on_load() + bread.on("bread.power.battery.low", function(event) + if warned then return end + warned = true + local pct = event.data.battery_percent or "?" + bread.notify("Battery low (" .. pct .. "%). Plug in soon.", { + urgency = "critical", + title = "Battery", + timeout = 10000, + }) + end) + + bread.on("bread.power.ac.connected", function() + warned = false + end) +end + +return M