2026-02-24 15:39:48 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
import org.kde.plasma.plasmoid 2.0
|
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
2026-02-24 16:19:31 +00:00
|
|
|
import "logic/CpuReader.js" as Reader
|
|
|
|
|
import "logic/CpuWriter.js" as Writer
|
2026-02-24 15:39:48 +00:00
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: root
|
|
|
|
|
|
2026-02-24 16:19:31 +00:00
|
|
|
property int temperature: 0
|
|
|
|
|
property int currentPerf: 100
|
2026-02-24 15:39:48 +00:00
|
|
|
|
|
|
|
|
Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation
|
|
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
|
interval: 3000
|
|
|
|
|
running: true
|
|
|
|
|
repeat: true
|
|
|
|
|
triggeredOnStart: true
|
2026-02-24 16:19:31 +00:00
|
|
|
onTriggered: statusSource.connectSource(Reader.buildReadCommand())
|
2026-02-24 15:39:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PlasmaCore.DataSource {
|
2026-02-24 16:19:31 +00:00
|
|
|
id: statusSource
|
2026-02-24 15:39:48 +00:00
|
|
|
engine: "executable"
|
|
|
|
|
onNewData: {
|
2026-02-24 16:19:31 +00:00
|
|
|
var result = Reader.parseOutput(data["stdout"])
|
|
|
|
|
if (result.valid) {
|
|
|
|
|
root.temperature = result.tempC
|
|
|
|
|
root.currentPerf = result.perf
|
2026-02-24 15:39:48 +00:00
|
|
|
}
|
|
|
|
|
disconnectSource(sourceName)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PlasmaCore.DataSource {
|
2026-02-24 16:19:31 +00:00
|
|
|
id: writeSource
|
2026-02-24 15:39:48 +00:00
|
|
|
engine: "executable"
|
|
|
|
|
onNewData: {
|
|
|
|
|
disconnectSource(sourceName)
|
2026-02-24 16:19:31 +00:00
|
|
|
statusSource.connectSource(Reader.buildReadCommand())
|
2026-02-24 15:39:48 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-24 16:19:31 +00:00
|
|
|
function setPerf(value) {
|
|
|
|
|
var cmd = Writer.buildSetCommand(value)
|
|
|
|
|
if (cmd) writeSource.connectSource(cmd)
|
2026-02-24 15:39:48 +00:00
|
|
|
}
|
|
|
|
|
|
2026-02-24 16:19:31 +00:00
|
|
|
Plasmoid.compactRepresentation: CompactView {
|
|
|
|
|
temperature: root.temperature
|
|
|
|
|
onClicked: plasmoid.expanded = !plasmoid.expanded
|
2026-02-24 15:39:48 +00:00
|
|
|
}
|
|
|
|
|
|
2026-02-24 16:19:31 +00:00
|
|
|
Plasmoid.fullRepresentation: FullView {
|
|
|
|
|
temperature: root.temperature
|
|
|
|
|
currentPerf: root.currentPerf
|
|
|
|
|
onPerfChangeRequested: root.setPerf(newValue)
|
2026-02-24 15:39:48 +00:00
|
|
|
}
|
|
|
|
|
}
|