nova-shell/modules/Temperature.qml
2026-04-12 18:44:27 +02:00

41 lines
1.1 KiB
QML

import QtQuick
import Quickshell.Io
import "." as M
M.BarSection {
id: root
spacing: Math.max(1, M.Theme.moduleSpacing - 2)
tooltip: "Temperature: " + root.celsius + "\u00B0C"
property int celsius: 0
property color _stateColor: celsius > (M.Modules.temperature.hot || 80) ? M.Theme.base09 : celsius > (M.Modules.temperature.warm || 60) ? M.Theme.base0A : M.Theme.base08
Behavior on _stateColor {
ColorAnimation {
duration: 300
}
}
FileView {
id: thermal
path: "/sys/class/thermal/thermal_zone0/temp"
onLoaded: root.celsius = Math.round(parseInt(text()) / 1000)
}
Timer {
interval: M.Modules.temperature.interval || 2000
running: true
repeat: true
onTriggered: thermal.reload()
}
M.BarIcon {
icon: "\uF2C9"
color: root._stateColor
anchors.verticalCenter: parent.verticalCenter
}
M.BarLabel {
label: root.celsius + "\u00B0C"
minText: "100\u00B0C"
color: root._stateColor
anchors.verticalCenter: parent.verticalCenter
}
}