quickshell: glance adds temp + wan up/down

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-07-28 20:37:05 +01:00
parent 72864463d0
commit 608902915f

View file

@ -775,6 +775,29 @@ in
font.pixelSize: 16 font.pixelSize: 16
} }
// GlanceStat: a bar-column stat clock-sized value over a
// faded 9px caption (the server glance rows).
component GlanceStat: Column {
property alias value: _gsV.text
property alias caption: _gsC.text
property color valueColor: Theme.base05
anchors.horizontalCenter: parent.horizontalCenter
spacing: 0
SText {
id: _gsV
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: 15
font.weight: Font.Medium
color: parent.valueColor
}
SText {
id: _gsC
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: 9
color: Theme.base03
}
}
// VolIcon: a slider's volume glyph that toggles its audio // VolIcon: a slider's volume glyph that toggles its audio
// node's mute on click. Glyph reflects the mute state; pair it // node's mute on click. Glyph reflects the mute state; pair it
// with a fill that greys when `audioNode.muted`. // with a fill that greys when `audioNode.muted`.
@ -1760,6 +1783,22 @@ in
return Math.round(b) + " b/s"; return Math.round(b) + " b/s";
} }
// Split variants for the bar glance: number and unit
// live on separate lines, so both stay narrow.
function rateVal(bps) {
const b = bps * 8;
if (b >= 1e9) return (b / 1e9).toFixed(1);
if (b >= 1e7) return Math.round(b / 1e6).toString();
if (b >= 1e6) return (b / 1e6).toFixed(1);
return Math.round(b / 1e3).toString();
}
function rateUnit(bps) {
const b = bps * 8;
if (b >= 1e9) return "gb/s";
if (b >= 1e6) return "mb/s";
return "kb/s";
}
property var _procsPending: [] property var _procsPending: []
property bool _collecting: false property bool _collecting: false
@ -1846,69 +1885,46 @@ in
}); });
} }
// Labelled numbers, 15px Medium like the clock: // Stat stack, clock-sized values over faded captions.
// "cpu"/"ram" captions above their values, faded "ms"
// under the ping.
Column { Column {
id: srvGlanceCol id: srvGlanceCol
anchors.centerIn: parent anchors.centerIn: parent
spacing: 5 spacing: 5
Column { GlanceStat {
anchors.horizontalCenter: parent.horizontalCenter value: srvWidget.connected ? Math.round(srvWidget.cpu) + "%" : "--"
spacing: 0 caption: "cpu"
SText { valueColor: srvWidget.connected ? Theme.base0D : Theme.base03
anchors.horizontalCenter: parent.horizontalCenter
text: srvWidget.connected ? Math.round(srvWidget.cpu) + "%" : "--"
font.pixelSize: 15
font.weight: Font.Medium
color: srvWidget.connected ? Theme.base0D : Theme.base03
}
SText {
anchors.horizontalCenter: parent.horizontalCenter
text: "cpu"
font.pixelSize: 9
color: Theme.base03
}
} }
GlanceStat {
Column { value: srvWidget.connected && srvWidget.memTotal > 0
anchors.horizontalCenter: parent.horizontalCenter ? Math.round(100 * srvWidget.memUsed / srvWidget.memTotal) + "%" : "--"
spacing: 0 caption: "ram"
SText { valueColor: srvWidget.connected ? Theme.base0C : Theme.base03
anchors.horizontalCenter: parent.horizontalCenter
text: srvWidget.connected && srvWidget.memTotal > 0
? Math.round(100 * srvWidget.memUsed / srvWidget.memTotal) + "%" : "--"
font.pixelSize: 15
font.weight: Font.Medium
color: srvWidget.connected ? Theme.base0C : Theme.base03
}
SText {
anchors.horizontalCenter: parent.horizontalCenter
text: "ram"
font.pixelSize: 9
color: Theme.base03
}
} }
GlanceStat {
Column { value: srvWidget.connected && srvWidget.tempC >= 0 ? srvWidget.tempC + "°" : "--"
anchors.horizontalCenter: parent.horizontalCenter caption: "temp"
spacing: 0 valueColor: !srvWidget.connected || srvWidget.tempC < 0 ? Theme.base03
SText { : srvWidget.tempC >= 85 ? Theme.base08
anchors.horizontalCenter: parent.horizontalCenter : srvWidget.tempC >= 70 ? Theme.base0A : Theme.base05
text: srvWidget.pingMs < 0 ? "--" }
: srvWidget.pingMs < 10 ? srvWidget.pingMs.toFixed(1) GlanceStat {
: Math.round(srvWidget.pingMs).toString() value: srvWidget.connected ? srvWidget.rateVal(srvWidget.rxBps) : "--"
font.pixelSize: 15 caption: " " + srvWidget.rateUnit(srvWidget.rxBps)
font.weight: Font.Medium valueColor: srvWidget.connected ? Theme.base0B : Theme.base03
color: srvWidget.pingMs < 0 ? Theme.base03 : Theme.base04 }
} GlanceStat {
SText { value: srvWidget.connected ? srvWidget.rateVal(srvWidget.txBps) : "--"
anchors.horizontalCenter: parent.horizontalCenter caption: " " + srvWidget.rateUnit(srvWidget.txBps)
text: "ms" valueColor: srvWidget.connected ? Theme.base09 : Theme.base03
font.pixelSize: 9 }
color: Theme.base03 GlanceStat {
} value: srvWidget.pingMs < 0 ? "--"
: srvWidget.pingMs < 10 ? srvWidget.pingMs.toFixed(1)
: Math.round(srvWidget.pingMs).toString()
caption: "ms"
valueColor: srvWidget.pingMs < 0 ? Theme.base03 : Theme.base04
} }
} }