feat: added graphs to battery hover windows
This commit is contained in:
@@ -4,6 +4,7 @@ import Quickshell
|
||||
import Quickshell.Services.UPower
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property bool available: UPower.displayDevice.isLaptopBattery
|
||||
property real percentage: UPower.displayDevice.percentage*100
|
||||
property string state: UPowerDeviceState.toString(UPower.displayDevice.state)
|
||||
@@ -18,4 +19,38 @@ Item {
|
||||
property real energy_rate_formated: Math.round(energy_rate*10)/10
|
||||
property bool healthSupported: UPower.displayDevice.healthSupported
|
||||
property real health: healthSupported ? UPower.displayDevice.healthPercentage : NaN
|
||||
|
||||
property int _maxHistory: 60*60
|
||||
|
||||
property var percentageHistory: [{time: Date.now() - _maxHistory*1000, value: 0}, {time: Date.now(), value: 0}]
|
||||
property var energyHistory: [{time: Date.now() - _maxHistory*1000, value: 0}, {time: Date.now(), value: 0}]
|
||||
property var usageHistory: [{time: Date.now() - _maxHistory*1000, value: 0}, {time: Date.now(), value: 0}]
|
||||
|
||||
Timer {
|
||||
id: statsTimer
|
||||
interval: 1000
|
||||
repeat: true
|
||||
running: true
|
||||
onTriggered: {
|
||||
var now = Date.now()
|
||||
|
||||
// Creating percentage History
|
||||
var pHist = root.percentageHistory
|
||||
pHist.push({time: now, value: percentage})
|
||||
if (pHist.length > root._maxHistory) pHist.shift()
|
||||
root.percentageHistory = pHist
|
||||
|
||||
// Creating percentage History
|
||||
var eHist = root.energyHistory
|
||||
eHist.push({time: now, value: percentage})
|
||||
if (eHist.length > root._maxHistory) eHist.shift()
|
||||
root.energyHistory = eHist
|
||||
|
||||
// Creating percentage History
|
||||
var uHist = root.usageHistory
|
||||
uHist.push({time: now, value: percentage})
|
||||
if (uHist.length > root._maxHistory) uHist.shift()
|
||||
root.usageHistory = uHist
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user