diff --git a/settings/quickshell.nix b/settings/quickshell.nix index 3b566a6..b8fda94 100644 --- a/settings/quickshell.nix +++ b/settings/quickshell.nix @@ -775,6 +775,29 @@ in 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 // node's mute on click. Glyph reflects the mute state; pair it // with a fill that greys when `audioNode.muted`. @@ -1760,6 +1783,22 @@ in 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 bool _collecting: false @@ -1846,69 +1885,46 @@ in }); } - // Labelled numbers, 15px Medium like the clock: - // "cpu"/"ram" captions above their values, faded "ms" - // under the ping. + // Stat stack, clock-sized values over faded captions. Column { id: srvGlanceCol anchors.centerIn: parent spacing: 5 - Column { - anchors.horizontalCenter: parent.horizontalCenter - spacing: 0 - SText { - 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 { + value: srvWidget.connected ? Math.round(srvWidget.cpu) + "%" : "--" + caption: "cpu" + valueColor: srvWidget.connected ? Theme.base0D : Theme.base03 } - - Column { - anchors.horizontalCenter: parent.horizontalCenter - spacing: 0 - SText { - 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 { + value: srvWidget.connected && srvWidget.memTotal > 0 + ? Math.round(100 * srvWidget.memUsed / srvWidget.memTotal) + "%" : "--" + caption: "ram" + valueColor: srvWidget.connected ? Theme.base0C : Theme.base03 } - - Column { - anchors.horizontalCenter: parent.horizontalCenter - spacing: 0 - SText { - anchors.horizontalCenter: parent.horizontalCenter - text: srvWidget.pingMs < 0 ? "--" - : srvWidget.pingMs < 10 ? srvWidget.pingMs.toFixed(1) - : Math.round(srvWidget.pingMs).toString() - font.pixelSize: 15 - font.weight: Font.Medium - color: srvWidget.pingMs < 0 ? Theme.base03 : Theme.base04 - } - SText { - anchors.horizontalCenter: parent.horizontalCenter - text: "ms" - font.pixelSize: 9 - color: Theme.base03 - } + GlanceStat { + value: srvWidget.connected && srvWidget.tempC >= 0 ? srvWidget.tempC + "°" : "--" + caption: "temp" + valueColor: !srvWidget.connected || srvWidget.tempC < 0 ? Theme.base03 + : srvWidget.tempC >= 85 ? Theme.base08 + : srvWidget.tempC >= 70 ? Theme.base0A : Theme.base05 + } + GlanceStat { + value: srvWidget.connected ? srvWidget.rateVal(srvWidget.rxBps) : "--" + caption: "↓ " + srvWidget.rateUnit(srvWidget.rxBps) + valueColor: srvWidget.connected ? Theme.base0B : Theme.base03 + } + GlanceStat { + value: srvWidget.connected ? srvWidget.rateVal(srvWidget.txBps) : "--" + caption: "↑ " + srvWidget.rateUnit(srvWidget.txBps) + valueColor: srvWidget.connected ? Theme.base09 : 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 } }