Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions desktop/shell/shell/plugins/panels/power/Status.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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
Expand Down