Add battery health to battery popup (#2355)

This commit is contained in:
end-4
2025-11-06 21:15:04 +01:00
committed by GitHub
2 changed files with 43 additions and 0 deletions
@@ -31,6 +31,25 @@ Singleton {
property real timeToEmpty: UPower.displayDevice.timeToEmpty
property real timeToFull: UPower.displayDevice.timeToFull
property real health: (function() {
const devList = UPower.devices.values;
for (let i = 0; i < devList.length; ++i) {
const dev = devList[i];
if (dev.isLaptopBattery && dev.healthSupported) {
const health = dev.healthPercentage;
if (health === 0) {
return 0.01;
} else if (health < 1) {
return health * 100;
} else {
return health;
}
}
}
return 0;
})()
onIsLowAndNotChargingChanged: {
if (!root.available || !isLowAndNotCharging) return;
Quickshell.execDetached([