From f7e3ed909902327a6d228187ffa43974d98c1f17 Mon Sep 17 00:00:00 2001 From: Chris Durham <47431093+cDurham@users.noreply.github.com> Date: Fri, 4 Dec 2026 11:18:49 -0700 Subject: [PATCH] The battery reading: on a change, not every second The shell ran omarchy-battery-status once a second for as long as it ran, in each of the three places that show the battery. Each run starts bash and one or two awk: several process launches every second on a two-core tablet, only to redraw a percentage that moves once in minutes. Read it when UPower says the charger went in or out or the percentage moved, and every 30 seconds besides, so discovery still does not depend on UPower. The open power panel reads every second as before. Assisted-by: LLM Co-Authored-By: Claude Fable 5.2 Signed-off-by: Chris Durham <47431093+cDurham@users.noreply.github.com> --- .../shell/plugins/panels/power/Status.qml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/desktop/shell/shell/plugins/panels/power/Status.qml b/desktop/shell/shell/plugins/panels/power/Status.qml index d668d8d8..20dab8e4 100644 --- a/desktop/shell/shell/plugins/panels/power/Status.qml +++ b/desktop/shell/shell/plugins/panels/power/Status.qml @@ -11,8 +11,10 @@ Item { id: root visible: false - // The battery script's readings (omarchy-battery-status --shell), read - // every second: discovery must not depend on a charger event or on UPower. + // The battery script's readings (omarchy-battery-status --shell). Each read + // starts bash and awk, which costs too much CPU to do every second. So it + // reads when UPower reports a change, and every 30 seconds as a fallback, + // so that finding the battery does not depend on UPower. property var batteryInfo: ({}) readonly property bool externalPower: batteryInfo.external_power === "connected" readonly property var batteryDevice: { @@ -57,8 +59,18 @@ Item { stdout: StdioCollector { waitForEnd: true; onStreamFinished: root.updateKeyValue(text) } } + Connections { + target: UPower + function onOnBatteryChanged() { root.refresh() } + } + + Connections { + target: UPower.displayDevice + function onPercentageChanged() { root.refresh() } + } + Timer { - interval: 1000 + interval: 30000 running: true repeat: true triggeredOnStart: true