fixes waybar, adds quickshell
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// TemperatureWidget.qml - CPU package temperature
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
import ".."
|
||||
|
||||
Pill {
|
||||
id: root
|
||||
property int tempC: 0
|
||||
property bool critical: tempC >= 80
|
||||
|
||||
property string icon: tempC < 50 ? "" : tempC < 70 ? "" : ""
|
||||
|
||||
onClicked: (m) => {
|
||||
if (m.button === Qt.LeftButton) Exec.run(["xsensors"])
|
||||
}
|
||||
|
||||
Text {
|
||||
text: root.icon + " " + root.tempC + "°C"
|
||||
font.family: Theme.fontSans
|
||||
font.pixelSize: Theme.fontSize
|
||||
color: root.critical ? Theme.color1 : Theme.foreground
|
||||
}
|
||||
|
||||
// Read first available CPU package sensor - works regardless of hwmon number
|
||||
Process {
|
||||
id: tempProc
|
||||
running: false
|
||||
command: ["bash", "-c", "cat /sys/class/hwmon/hwmon*/temp1_input 2>/dev/null | head -1"]
|
||||
stdout: SplitParser {
|
||||
onRead: (line) => {
|
||||
const raw = parseInt(line.trim())
|
||||
if (!isNaN(raw)) root.tempC = Math.round(raw / 1000)
|
||||
}
|
||||
}
|
||||
onExited: tempProc.running = false
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 4000; running: true; repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: tempProc.running = true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user