forked from Shinonome/dots-hyprland
Removed helper script and made workaround in qml
This commit is contained in:
@@ -1,16 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# This just guesses that the BAT0 is the actuall battery
|
|
||||||
# because BAT0 is the default for modern systems
|
|
||||||
full=$(cat /sys/class/power_supply/BAT0/charge_full)
|
|
||||||
design=$(cat /sys/class/power_supply/BAT0/charge_full_design)
|
|
||||||
|
|
||||||
if [ "$design" -gt 0 ]; then # basically if design > 0
|
|
||||||
awk "BEGIN { printf \"%.1f\n\", ($full/$design)*100 }"
|
|
||||||
else
|
|
||||||
echo "Error"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If you have any issues try to find your "real" battery.
|
|
||||||
# Run 'ls /sys/class/power_supply'. You may see BATM or BAT1 and no BAT0
|
|
||||||
# You can check what is what my running 'cat /sys/class/power_supply/{whatever_you_got}/model_name'
|
|
||||||
@@ -32,27 +32,29 @@ Singleton {
|
|||||||
property real timeToEmpty: UPower.displayDevice.timeToEmpty
|
property real timeToEmpty: UPower.displayDevice.timeToEmpty
|
||||||
property real timeToFull: UPower.displayDevice.timeToFull
|
property real timeToFull: UPower.displayDevice.timeToFull
|
||||||
|
|
||||||
property real health: 0
|
property real health: (function() {
|
||||||
Process {
|
if (!Config.options.battery.showHealth) {
|
||||||
id: batteryProcess
|
return 0;
|
||||||
running: Config.options.battery.showHealth
|
}
|
||||||
command: [
|
|
||||||
"bash",
|
|
||||||
`${FileUtils.trimFileProtocol(Directories.scriptPath)}/battery/calculate-health.sh`
|
|
||||||
]
|
|
||||||
|
|
||||||
stdout: StdioCollector {
|
const devList = UPower.devices.values;
|
||||||
onStreamFinished: {
|
for (let i = 0; i < devList.length; ++i) {
|
||||||
const output = text.trim()
|
const dev = devList[i];
|
||||||
const value = Number(output)
|
if (dev.isLaptopBattery && dev.healthSupported) {
|
||||||
if (!isNaN(value)) {
|
const health = dev.healthPercentage;
|
||||||
root.health = value
|
if (health === 0) {
|
||||||
|
return 0;
|
||||||
|
} else if (health < 1) {
|
||||||
|
return health * 100;
|
||||||
} else {
|
} else {
|
||||||
console.warn("Battery script output invalid:", output)
|
return health;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return 0;
|
||||||
|
})()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onIsLowAndNotChargingChanged: {
|
onIsLowAndNotChargingChanged: {
|
||||||
if (!root.available || !isLowAndNotCharging) return;
|
if (!root.available || !isLowAndNotCharging) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user