Compare commits
2 commits
dd5ca9d263
...
4d730f51f3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d730f51f3 | ||
|
|
3854763ce5 |
5 changed files with 44 additions and 33 deletions
|
|
@ -55,7 +55,6 @@ QtObject {
|
||||||
})
|
})
|
||||||
property var temperature: ({
|
property var temperature: ({
|
||||||
enable: true,
|
enable: true,
|
||||||
interval: 2000,
|
|
||||||
warm: 80,
|
warm: 80,
|
||||||
hot: 90
|
hot: 90
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ QtObject {
|
||||||
property var cpuCoreMaxFreq: []
|
property var cpuCoreMaxFreq: []
|
||||||
property var cpuCoreTypes: []
|
property var cpuCoreTypes: []
|
||||||
|
|
||||||
|
// ── Temperature ──────────────────────────────────────────────────────
|
||||||
|
property int tempCelsius: 0
|
||||||
|
|
||||||
// ── Memory ───────────────────────────────────────────────────────────
|
// ── Memory ───────────────────────────────────────────────────────────
|
||||||
property int memPercent: 0
|
property int memPercent: 0
|
||||||
property real memUsedGb: 0
|
property real memUsedGb: 0
|
||||||
|
|
@ -52,6 +55,8 @@ QtObject {
|
||||||
history: hist.length > histLen ? hist.slice(hist.length - histLen) : hist
|
history: hist.length > histLen ? hist.slice(hist.length - histLen) : hist
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
} else if (ev.type === "temp") {
|
||||||
|
root.tempCelsius = ev.celsius;
|
||||||
} else if (ev.type === "mem") {
|
} else if (ev.type === "mem") {
|
||||||
root.memPercent = ev.percent;
|
root.memPercent = ev.percent;
|
||||||
root.memUsedGb = ev.used_gb;
|
root.memUsedGb = ev.used_gb;
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,25 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell.Io
|
|
||||||
import "." as M
|
import "." as M
|
||||||
|
|
||||||
M.BarSection {
|
M.BarSection {
|
||||||
id: root
|
id: root
|
||||||
spacing: Math.max(1, M.Theme.moduleSpacing - 2)
|
spacing: Math.max(1, M.Theme.moduleSpacing - 2)
|
||||||
tooltip: "Temperature: " + root.celsius + "\u00B0C"
|
tooltip: "Temperature: " + M.SystemStats.tempCelsius + "\u00B0C"
|
||||||
|
|
||||||
property int celsius: 0
|
property color _stateColor: M.SystemStats.tempCelsius > (M.Modules.temperature.hot || 80) ? M.Theme.base09 : M.SystemStats.tempCelsius > (M.Modules.temperature.warm || 60) ? M.Theme.base0A : root.accentColor
|
||||||
property color _stateColor: celsius > (M.Modules.temperature.hot || 80) ? M.Theme.base09 : celsius > (M.Modules.temperature.warm || 60) ? M.Theme.base0A : root.accentColor
|
|
||||||
Behavior on _stateColor {
|
Behavior on _stateColor {
|
||||||
ColorAnimation {
|
ColorAnimation {
|
||||||
duration: 300
|
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 {
|
M.BarIcon {
|
||||||
icon: "\uF2C9"
|
icon: "\uF2C9"
|
||||||
color: root._stateColor
|
color: root._stateColor
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
M.BarLabel {
|
M.BarLabel {
|
||||||
label: root.celsius + "\u00B0C"
|
label: M.SystemStats.tempCelsius + "\u00B0C"
|
||||||
minText: "100\u00B0C"
|
minText: "100\u00B0C"
|
||||||
color: root._stateColor
|
color: root._stateColor
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
|
||||||
|
|
@ -127,21 +127,18 @@ in
|
||||||
description = "Brightness adjustment step (%).";
|
description = "Brightness adjustment step (%).";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
temperature = moduleOpt "temperature" (
|
temperature = moduleOpt "temperature" {
|
||||||
(intervalOpt 2000)
|
warm = lib.mkOption {
|
||||||
// {
|
type = lib.types.int;
|
||||||
warm = lib.mkOption {
|
default = 80;
|
||||||
type = lib.types.int;
|
description = "Temperature threshold for warm state (°C).";
|
||||||
default = 80;
|
};
|
||||||
description = "Temperature threshold for warm state (°C).";
|
hot = lib.mkOption {
|
||||||
};
|
type = lib.types.int;
|
||||||
hot = lib.mkOption {
|
default = 90;
|
||||||
type = lib.types.int;
|
description = "Temperature threshold for hot state (°C).";
|
||||||
default = 90;
|
};
|
||||||
description = "Temperature threshold for hot state (°C).";
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
battery = moduleOpt "battery" {
|
battery = moduleOpt "battery" {
|
||||||
warning = lib.mkOption {
|
warning = lib.mkOption {
|
||||||
type = lib.types.int;
|
type = lib.types.int;
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,23 @@ fn read_stat() -> Vec<Sample> {
|
||||||
parse_stat(&fs::read_to_string("/proc/stat").unwrap_or_default())
|
parse_stat(&fs::read_to_string("/proc/stat").unwrap_or_default())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn read_temp_celsius() -> Option<i32> {
|
||||||
|
let mut max: Option<i32> = None;
|
||||||
|
for i in 0.. {
|
||||||
|
let path = format!("/sys/class/thermal/thermal_zone{i}/temp");
|
||||||
|
match fs::read_to_string(&path) {
|
||||||
|
Ok(s) => {
|
||||||
|
if let Ok(millic) = s.trim().parse::<i32>() {
|
||||||
|
let c = millic / 1000;
|
||||||
|
max = Some(max.map_or(c, |m: i32| m.max(c)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(_) => break,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
max
|
||||||
|
}
|
||||||
|
|
||||||
fn read_core_freqs() -> Vec<f64> {
|
fn read_core_freqs() -> Vec<f64> {
|
||||||
let mut freqs = Vec::new();
|
let mut freqs = Vec::new();
|
||||||
for i in 0.. {
|
for i in 0.. {
|
||||||
|
|
@ -148,6 +165,12 @@ fn emit_cpu(out: &mut impl Write, prev: &[Sample], curr: &[Sample], freqs: &[f64
|
||||||
let _ = writeln!(out, "]}}");
|
let _ = writeln!(out, "]}}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn emit_temp(out: &mut impl Write) {
|
||||||
|
if let Some(c) = read_temp_celsius() {
|
||||||
|
let _ = writeln!(out, "{{\"type\":\"temp\",\"celsius\":{c}}}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn emit_mem(out: &mut impl Write) {
|
fn emit_mem(out: &mut impl Write) {
|
||||||
let content = fs::read_to_string("/proc/meminfo").unwrap_or_default();
|
let content = fs::read_to_string("/proc/meminfo").unwrap_or_default();
|
||||||
if let Some(m) = parse_meminfo(&content) {
|
if let Some(m) = parse_meminfo(&content) {
|
||||||
|
|
@ -190,6 +213,7 @@ fn main() {
|
||||||
|
|
||||||
if tick.is_multiple_of(2) {
|
if tick.is_multiple_of(2) {
|
||||||
emit_mem(&mut out);
|
emit_mem(&mut out);
|
||||||
|
emit_temp(&mut out);
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = out.flush();
|
let _ = out.flush();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue