diff --git a/README.md b/README.md index e0ae5ff..4bde28d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Weather && Stats -A KDE Plasma 6 panel widget that displays live weather and system stats in a single compact bar. +A KDE Plasma 6 **panel/taskbar widget** that displays live weather and system stats in a single compact bar. Designed to sit in your top or bottom panel — not a desktop widget. ![Plasma 6](https://img.shields.io/badge/Plasma-6.0+-blue) ![License](https://img.shields.io/badge/License-GPL--2.0-green) @@ -20,8 +20,8 @@ All stats update on configurable intervals. Each section can be toggled on or of ## Requirements - KDE Plasma 6.0+ -- A [Nerd Font](https://www.nerdfonts.com/) set as your panel font (for icons) - `bash`, `free`, `/proc/stat`, `/proc/net/dev` (standard on any Linux system) +- A [Nerd Font](https://www.nerdfonts.com/) set as your panel font is **optional** — the widget falls back to plain Unicode symbols if disabled in settings ## Installation @@ -34,6 +34,8 @@ kpackagetool6 --type Plasma/Applet --install weather-and-stats Then right-click your panel → **Add Widgets** → search for **Weather && Stats**. +> **Placement:** Plasma always adds new widgets at a default position. After adding, right-click your panel → **Enter Edit Mode** and drag the widget to your preferred spot (e.g. left of the system tray). Plasma has no API for widgets to declare a position automatically. + ### To update after changes ```bash @@ -54,6 +56,7 @@ Right-click the widget → **Configure Weather && Stats**: | CPU temp alert threshold | Temp at which the reading turns red | 80°C | | Stats refresh | How often to poll system stats (seconds) | 3 sec | | Visible stats | Toggle CPU temp, CPU usage, memory, network | All on | +| Use Nerd Font icons | Use Nerd Font glyphs; disable for plain Unicode fallback | On | ## How it works diff --git a/contents/ui/main.qml b/contents/ui/main.qml index e19e8a4..e037a0e 100644 --- a/contents/ui/main.qml +++ b/contents/ui/main.qml @@ -66,74 +66,37 @@ PlasmoidItem { // ── Panel display ───────────────────────────────────────────────────────── preferredRepresentation: fullRepresentation - fullRepresentation: RowLayout { + fullRepresentation: PlasmaComponents.Label { Layout.fillHeight: true - spacing: 0 + Layout.preferredWidth: implicitWidth + 16 + verticalAlignment: Text.AlignVCenter + textFormat: Text.RichText - // ── Main label (weather + cpu/mem) ──────────────────────────────────── - PlasmaComponents.Label { - Layout.fillHeight: true - Layout.preferredWidth: implicitWidth + 16 - verticalAlignment: Text.AlignVCenter - textFormat: Text.RichText + text: { + var hot = root.cpuTempRaw > 0 && root.cpuTempRaw >= root.cpuTempThreshold + var sp = "\u00a0\u00a0\u00a0\u00a0" + var div = "\u00a0\u00a0\u2502\u00a0\u00a0" - text: { - var hot = root.cpuTempRaw > 0 && root.cpuTempRaw >= root.cpuTempThreshold - var sp = "\u00a0\u00a0\u00a0\u00a0" - var div = "\u00a0\u00a0\u2502\u00a0\u00a0" + var s = root.weatherIcon + "\u00a0\u00a0" + root.temperature + "°" + (root.fahrenheit ? "F" : "C") + if (root.showCondition && root.weatherCondition !== "") + s += " " + root.weatherCondition - var s = root.weatherIcon + "\u00a0\u00a0" + root.temperature + "°" + (root.fahrenheit ? "F" : "C") - if (root.showCondition && root.weatherCondition !== "") - s += " " + root.weatherCondition - - var cpuMem = [] - if (root.showCpuTemp) { - var tempStr = root.ic.cpuTemp + "\u00a0\u00a0" + root.cpuTempDisplay - cpuMem.push(hot ? "" + tempStr + "" : tempStr) - } - if (root.showCpuUsage) - cpuMem.push(root.ic.cpu + "\u00a0\u00a0" + (root.cpuUsage >= 0 ? padPct(root.cpuUsage) : "\u00a0--")) - if (root.showMemory) - cpuMem.push(root.ic.mem + "\u00a0\u00a0" + (root.memUsage >= 0 ? padPct(root.memUsage) : "\u00a0--")) - - if (cpuMem.length > 0) s += div + cpuMem.join(sp) - if (root.showNetwork) s += div - - return s + var cpuMem = [] + if (root.showCpuTemp) { + var tempStr = root.ic.cpuTemp + "\u00a0\u00a0" + root.cpuTempDisplay + cpuMem.push(hot ? "" + tempStr + "" : tempStr) } - } + if (root.showCpuUsage) + cpuMem.push(root.ic.cpu + "\u00a0\u00a0" + (root.cpuUsage >= 0 ? padPct(root.cpuUsage) : "\u00a0--")) + if (root.showMemory) + cpuMem.push(root.ic.mem + "\u00a0\u00a0" + (root.memUsage >= 0 ? padPct(root.memUsage) : "\u00a0--")) - // ── Network ─────────────────────────────────────────────────────────── - // A hidden reference label measures the pixel width of the widest - // possible value. Both visible labels are pinned to that exact width - // (min = preferred = max) so content changes never affect their size. - PlasmaComponents.Label { - id: netRef - visible: false - font.family: "monospace" - text: "000 MB/s" - } + if (cpuMem.length > 0) s += div + cpuMem.join(sp) - PlasmaComponents.Label { - visible: root.showNetwork - font.family: "monospace" - Layout.fillHeight: true - Layout.minimumWidth: netRef.implicitWidth - Layout.preferredWidth: netRef.implicitWidth - Layout.maximumWidth: netRef.implicitWidth - verticalAlignment: Text.AlignVCenter - text: root.ic.down + " " + formatNetSpeed(root.netDown) - } + if (root.showNetwork) + s += div + root.ic.down + "\u00a0\u00a0" + formatNetSpeed(root.netDown) + sp + root.ic.up + "\u00a0\u00a0" + formatNetSpeed(root.netUp) - PlasmaComponents.Label { - visible: root.showNetwork - font.family: "monospace" - Layout.fillHeight: true - Layout.minimumWidth: netRef.implicitWidth - Layout.preferredWidth: netRef.implicitWidth - Layout.maximumWidth: netRef.implicitWidth - verticalAlignment: Text.AlignVCenter - text: " " + root.ic.up + " " + formatNetSpeed(root.netUp) + " " + return s + " " } } diff --git a/metadata.json b/metadata.json index aea210c..22b1b89 100644 --- a/metadata.json +++ b/metadata.json @@ -4,7 +4,7 @@ "Description": "Live weather and system stats for the KDE panel", "Icon": "weather-clear", "Id": "com.github.samjage.weatherstats", - "Version": "1.0", + "Version": "1.1", "License": "GPL-2.0", "Category": "System Information", "Authors": [