From 1d13bbe0f777d6dca6f55a7d776c8f8f4a7afcff Mon Sep 17 00:00:00 2001 From: quadbyte Date: Sun, 10 Aug 2025 13:26:46 -0400 Subject: [PATCH] Code formatting --- Modules/SidePanel/MediaCard.qml | 9 +++-- Modules/SidePanel/ProfileCard.qml | 26 +++++++++---- Modules/SidePanel/SidePanel.qml | 65 +++++++++++++++++++++---------- Modules/SidePanel/SystemCard.qml | 51 ++++++++++++++++++++---- Modules/SidePanel/WeatherCard.qml | 25 +++++++++--- Services/Scaling.qml | 4 +- Services/Settings.qml | 3 +- Widgets/NBox.qml | 1 - Widgets/NCard.qml | 1 - Widgets/NCircleStat.qml | 3 +- Widgets/NSystemMonitor.qml | 58 ++++++++++++--------------- 11 files changed, 161 insertions(+), 85 deletions(-) diff --git a/Modules/SidePanel/MediaCard.qml b/Modules/SidePanel/MediaCard.qml index 193b579..6e574f9 100644 --- a/Modules/SidePanel/MediaCard.qml +++ b/Modules/SidePanel/MediaCard.qml @@ -22,7 +22,9 @@ NBox { anchors.margins: Style.marginXL * scaling spacing: Style.marginSmall * scaling - Item { height: 36 * scaling } + Item { + height: 36 * scaling + } Text { text: "music_note" @@ -38,7 +40,8 @@ NBox { anchors.horizontalCenter: parent.horizontalCenter } - Item { height: 36 * scaling } + Item { + height: 36 * scaling + } } } - diff --git a/Modules/SidePanel/ProfileCard.qml b/Modules/SidePanel/ProfileCard.qml index c04da96..cd75e56 100644 --- a/Modules/SidePanel/ProfileCard.qml +++ b/Modules/SidePanel/ProfileCard.qml @@ -27,7 +27,7 @@ NBox { id: avatarBox width: 40 * scaling height: 40 * scaling - + Image { id: avatarImage anchors.fill: parent @@ -52,17 +52,29 @@ NBox { ColumnLayout { Layout.fillWidth: true spacing: 2 * scaling - NText { text: Quickshell.env("USER") || "user" } - NText { text: "System Uptime: —"; color: Colors.textSecondary } + NText { + text: Quickshell.env("USER") || "user" + } + NText { + text: "System Uptime: —" + color: Colors.textSecondary + } } RowLayout { spacing: Style.marginSmall * scaling Layout.alignment: Qt.AlignRight | Qt.AlignVCenter - Item { Layout.fillWidth: true } - NIconButton { icon: "settings"; sizeMultiplier: 0.8 } - NIconButton { icon: "power_settings_new"; sizeMultiplier: 0.8 } + Item { + Layout.fillWidth: true + } + NIconButton { + icon: "settings" + sizeMultiplier: 0.8 + } + NIconButton { + icon: "power_settings_new" + sizeMultiplier: 0.8 + } } } } - diff --git a/Modules/SidePanel/SidePanel.qml b/Modules/SidePanel/SidePanel.qml index 541f171..39796b7 100644 --- a/Modules/SidePanel/SidePanel.qml +++ b/Modules/SidePanel/SidePanel.qml @@ -6,7 +6,6 @@ import Quickshell.Wayland import qs.Services import qs.Widgets - NLoader { id: root @@ -46,7 +45,6 @@ NLoader { Component.onCompleted: show() // Inline helpers moved to dedicated widgets: NCard and NCircleStat - Rectangle { id: panelBackground color: Colors.backgroundPrimary @@ -61,13 +59,14 @@ NLoader { // Place the panel just below the bar (overlay content starts below bar due to topMargin) y: Style.marginSmall * scaling // Center horizontally under the anchorX, clamped to the screen bounds - x: Math.max( - Style.marginSmall * scaling, - Math.min(parent.width - width - Style.marginSmall * scaling, + x: Math.max(Style.marginSmall * scaling, Math.min( + parent.width - width - Style.marginSmall * scaling, Math.round(anchorX - width / 2))) // Prevent closing when clicking in the panel bg - MouseArea { anchors.fill: parent } + MouseArea { + anchors.fill: parent + } // Content wrapper to ensure childrenRect drives implicit height Item { @@ -88,8 +87,14 @@ NLoader { spacing: sidePanel.cardSpacing // Cards (consistent inter-card spacing via ColumnLayout spacing) - ProfileCard { Layout.topMargin: 0; Layout.bottomMargin: 0 } - WeatherCard { Layout.topMargin: 0; Layout.bottomMargin: 0 } + ProfileCard { + Layout.topMargin: 0 + Layout.bottomMargin: 0 + } + WeatherCard { + Layout.topMargin: 0 + Layout.bottomMargin: 0 + } // Middle section: media + stats column RowLayout { @@ -99,10 +104,16 @@ NLoader { spacing: sidePanel.cardSpacing // Media card - MediaCard { id: mediaCard; Layout.fillWidth: true; implicitHeight: statsCard.implicitHeight } + MediaCard { + id: mediaCard + Layout.fillWidth: true + implicitHeight: statsCard.implicitHeight + } // System monitors combined in one card - SystemCard { id: statsCard } + SystemCard { + id: statsCard + } } // Bottom actions (two grouped rows of round buttons) @@ -111,7 +122,7 @@ NLoader { Layout.topMargin: 0 Layout.bottomMargin: 0 spacing: sidePanel.cardSpacing - + // Power Profiles: performance, balanced, eco NBox { Layout.fillWidth: true @@ -122,26 +133,30 @@ NLoader { anchors.fill: parent anchors.margins: Style.marginSmall * scaling spacing: sidePanel.cardSpacing - Item { Layout.fillWidth: true } + Item { + Layout.fillWidth: true + } // Performance NIconButton { icon: "speed" sizeMultiplier: 1.0 - onClicked: function () { /* TODO: hook to power profile */ } + onClicked: function () {/* TODO: hook to power profile */ } } // Balanced NIconButton { icon: "balance" sizeMultiplier: 1.0 - onClicked: function () { /* TODO: hook to power profile */ } + onClicked: function () {/* TODO: hook to power profile */ } } // Eco NIconButton { icon: "eco" sizeMultiplier: 1.0 - onClicked: function () { /* TODO: hook to power profile */ } + onClicked: function () {/* TODO: hook to power profile */ } + } + Item { + Layout.fillWidth: true } - Item { Layout.fillWidth: true } } } @@ -155,12 +170,22 @@ NLoader { anchors.fill: parent anchors.margins: Style.marginSmall * scaling spacing: sidePanel.cardSpacing - Item { Layout.fillWidth: true } + Item { + Layout.fillWidth: true + } // Record - NIconButton { icon: "fiber_manual_record"; sizeMultiplier: 1.0 } + NIconButton { + icon: "fiber_manual_record" + sizeMultiplier: 1.0 + } // Wallpaper - NIconButton { icon: "image"; sizeMultiplier: 1.0 } - Item { Layout.fillWidth: true } + NIconButton { + icon: "image" + sizeMultiplier: 1.0 + } + Item { + Layout.fillWidth: true + } } } } diff --git a/Modules/SidePanel/SystemCard.qml b/Modules/SidePanel/SystemCard.qml index 57e0441..f66c405 100644 --- a/Modules/SidePanel/SystemCard.qml +++ b/Modules/SidePanel/SystemCard.qml @@ -24,17 +24,52 @@ NBox { spacing: Style.marginSmall * scaling // Slight top padding - Item { height: Style.marginTiny * scaling } + Item { + height: Style.marginTiny * scaling + } - NSystemMonitor { id: sysMon; intervalSeconds: 1 } + NSystemMonitor { + id: sysMon + intervalSeconds: 1 + } - NCircleStat { value: sysMon.cpuUsage || SysInfo.cpuUsage; icon: "speed"; flat: true; contentScale: 0.8; width: 72 * scaling; height: 68 * scaling } - NCircleStat { value: sysMon.cpuTemp || SysInfo.cpuTemp; suffix: "°C"; icon: "device_thermostat"; flat: true; contentScale: 0.8; width: 72 * scaling; height: 68 * scaling } - NCircleStat { value: sysMon.memoryUsagePer || SysInfo.memoryUsagePer; icon: "memory"; flat: true; contentScale: 0.8; width: 72 * scaling; height: 68 * scaling } - NCircleStat { value: sysMon.diskUsage || SysInfo.diskUsage; icon: "data_usage"; flat: true; contentScale: 0.8; width: 72 * scaling; height: 68 * scaling } + NCircleStat { + value: sysMon.cpuUsage || SysInfo.cpuUsage + icon: "speed" + flat: true + contentScale: 0.8 + width: 72 * scaling + height: 68 * scaling + } + NCircleStat { + value: sysMon.cpuTemp || SysInfo.cpuTemp + suffix: "°C" + icon: "device_thermostat" + flat: true + contentScale: 0.8 + width: 72 * scaling + height: 68 * scaling + } + NCircleStat { + value: sysMon.memoryUsagePer || SysInfo.memoryUsagePer + icon: "memory" + flat: true + contentScale: 0.8 + width: 72 * scaling + height: 68 * scaling + } + NCircleStat { + value: sysMon.diskUsage || SysInfo.diskUsage + icon: "data_usage" + flat: true + contentScale: 0.8 + width: 72 * scaling + height: 68 * scaling + } // Extra bottom padding to shift the perceived stack slightly upward - Item { height: Style.marginMedium * scaling } + Item { + height: Style.marginMedium * scaling + } } } - diff --git a/Modules/SidePanel/WeatherCard.qml b/Modules/SidePanel/WeatherCard.qml index 359f8d1..a9881fc 100644 --- a/Modules/SidePanel/WeatherCard.qml +++ b/Modules/SidePanel/WeatherCard.qml @@ -30,12 +30,21 @@ NBox { color: Colors.accentSecondary } ColumnLayout { - NText { text: "Dinslaken (GMT+2)" } - NText { text: "26°C"; font.pointSize: (Style.fontSizeXL + 6) * scaling } + NText { + text: "Dinslaken (GMT+2)" + } + NText { + text: "26°C" + font.pointSize: (Style.fontSizeXL + 6) * scaling + } } } - Rectangle { height: 1; width: parent.width; color: Colors.backgroundTertiary } + Rectangle { + height: 1 + width: parent.width + color: Colors.backgroundTertiary + } RowLayout { Layout.fillWidth: true @@ -44,16 +53,20 @@ NBox { model: 5 delegate: ColumnLayout { spacing: 2 * scaling - NText { text: ["Sun","Mon","Tue","Wed","Thu"][index] } + NText { + text: ["Sun", "Mon", "Tue", "Wed", "Thu"][index] + } Text { text: index % 2 === 0 ? "wb_sunny" : "cloud" font.family: "Material Symbols Outlined" color: Colors.textSecondary } - NText { text: "26° / 14°"; color: Colors.textSecondary } + NText { + text: "26° / 14°" + color: Colors.textSecondary + } } } } } } - diff --git a/Services/Scaling.qml b/Services/Scaling.qml index b921e14..912cee5 100644 --- a/Services/Scaling.qml +++ b/Services/Scaling.qml @@ -23,7 +23,9 @@ Singleton { const clamped = Math.max(0.6, Math.min(1.8, overrideScale)) return clamped } - } catch (e) {} + } catch (e) { + + } if (typeof aScreen !== 'undefined' & aScreen) { diff --git a/Services/Settings.qml b/Services/Settings.qml index 61eeafa..738a14f 100644 --- a/Services/Settings.qml +++ b/Services/Settings.qml @@ -17,8 +17,7 @@ Singleton { property var data: settingAdapter // Needed to only have one NPanel loaded at a time. - // property var openPanel: null - + // property var openPanel: null Item { Component.onCompleted: { // ensure settings dir diff --git a/Widgets/NBox.qml b/Widgets/NBox.qml index 2bc24b0..aa5a28d 100644 --- a/Widgets/NBox.qml +++ b/Widgets/NBox.qml @@ -17,4 +17,3 @@ Rectangle { border.width: Math.min(1, Style.borderThin * scaling) clip: true } - diff --git a/Widgets/NCard.qml b/Widgets/NCard.qml index 8901bb2..d0ff71d 100644 --- a/Widgets/NCard.qml +++ b/Widgets/NCard.qml @@ -15,4 +15,3 @@ Rectangle { border.color: Colors.backgroundTertiary border.width: Math.min(1, Style.borderThin * scaling) } - diff --git a/Widgets/NCircleStat.qml b/Widgets/NCircleStat.qml index 84d6a71..6ef5eaa 100644 --- a/Widgets/NCircleStat.qml +++ b/Widgets/NCircleStat.qml @@ -6,7 +6,7 @@ Rectangle { id: root readonly property real scaling: Scaling.scale(screen) - property real value: 0 // 0..100 (or any range visually mapped) + property real value: 0 // 0..100 (or any range visually mapped) property string icon: "" property string suffix: "%" @@ -109,4 +109,3 @@ Rectangle { } } } - diff --git a/Widgets/NSystemMonitor.qml b/Widgets/NSystemMonitor.qml index 1cb89da..05b4083 100644 --- a/Widgets/NSystemMonitor.qml +++ b/Widgets/NSystemMonitor.qml @@ -21,39 +21,29 @@ Item { Process { id: reader running: true - command: [ - "sh", "-c", - // Outputs: {"cpu":,"memper":,"cputemp":} - "interval=" + intervalSeconds + "; " + - "while true; do " + - // First /proc/stat snapshot - "read _ u1 n1 s1 id1 iw1 ir1 si1 st1 gs1 < /proc/stat; " + - "t1=$((u1+n1+s1+id1+iw1+ir1+si1+st1)); i1=$((id1+iw1)); " + - "sleep $interval; " + - // Second /proc/stat snapshot - "read _ u2 n2 s2 id2 iw2 ir2 si2 st2 gs2 < /proc/stat; " + - "t2=$((u2+n2+s2+id2+iw2+ir2+si2+st2)); i2=$((id2+iw2)); " + - "dt=$((t2 - t1)); di=$((i2 - i1)); " + - "cpu=$(( (100*(dt - di)) / (dt>0?dt:1) )); " + - // Memory percent via /proc/meminfo (kB) - "mt=$(awk '/MemTotal/ {print $2}' /proc/meminfo); " + - "ma=$(awk '/MemAvailable/ {print $2}' /proc/meminfo); " + - "mm=$((mt - ma)); mp=$(( (100*mm) / (mt>0?mt:1) )); " + - // Temperature: scan hwmon and thermal zones, choose max; convert m°C → °C - "ct=0; " + - "for f in /sys/class/hwmon/hwmon*/temp*_input /sys/class/thermal/thermal_zone*/temp; do " + - "[ -r \"$f\" ] || continue; v=$(cat \"$f\" 2>/dev/null); " + - "[ -z \"$v\" ] && continue; " + - "if [ \"$v\" -gt 1000 ] 2>/dev/null; then v=$((v/1000)); fi; " + - "[ \"$v\" -gt \"$ct\" ] 2>/dev/null && ct=$v; " + - "done; " + - // Disk usage percent for root filesystem - "dp=$(df -P / 2>/dev/null | awk 'NR==2{gsub(/%/,\"\",$5); print $5}'); " + - "[ -z \"$dp\" ] && dp=0; " + - // Emit JSON line - "echo \"{\\\"cpu\\\":$cpu,\\\"memper\\\":$mp,\\\"cputemp\\\":$ct,\\\"diskper\\\":$dp}\"; " + - "done" - ] + command: ["sh", "-c", // Outputs: {"cpu":,"memper":,"cputemp":} + "interval=" + intervalSeconds + "; " + "while true; do " + // First /proc/stat snapshot + "read _ u1 n1 s1 id1 iw1 ir1 si1 st1 gs1 < /proc/stat; " + + "t1=$((u1+n1+s1+id1+iw1+ir1+si1+st1)); i1=$((id1+iw1)); " + + "sleep $interval; " + // Second /proc/stat snapshot + "read _ u2 n2 s2 id2 iw2 ir2 si2 st2 gs2 < /proc/stat; " + + "t2=$((u2+n2+s2+id2+iw2+ir2+si2+st2)); i2=$((id2+iw2)); " + + "dt=$((t2 - t1)); di=$((i2 - i1)); " + "cpu=$(( (100*(dt - di)) / (dt>0?dt:1) )); " + + // Memory percent via /proc/meminfo (kB) + "mt=$(awk '/MemTotal/ {print $2}' /proc/meminfo); " + + "ma=$(awk '/MemAvailable/ {print $2}' /proc/meminfo); " + + "mm=$((mt - ma)); mp=$(( (100*mm) / (mt>0?mt:1) )); " + + // Temperature: scan hwmon and thermal zones, choose max; convert m°C → °C + "ct=0; " + + "for f in /sys/class/hwmon/hwmon*/temp*_input /sys/class/thermal/thermal_zone*/temp; do " + + "[ -r \"$f\" ] || continue; v=$(cat \"$f\" 2>/dev/null); " + "[ -z \"$v\" ] && continue; " + + "if [ \"$v\" -gt 1000 ] 2>/dev/null; then v=$((v/1000)); fi; " + + "[ \"$v\" -gt \"$ct\" ] 2>/dev/null && ct=$v; " + "done; " + + // Disk usage percent for root filesystem + "dp=$(df -P / 2>/dev/null | awk 'NR==2{gsub(/%/,\"\",$5); print $5}'); " + + "[ -z \"$dp\" ] && dp=0; " + // Emit JSON line + "echo \"{\\\"cpu\\\":$cpu,\\\"memper\\\":$mp,\\\"cputemp\\\":$ct,\\\"diskper\\\":$dp}\"; " + + "done"] stdout: SplitParser { onRead: function (line) { @@ -64,10 +54,10 @@ Item { root.memoryUsagePer = +data.memper root.diskUsage = +data.diskper } catch (e) { + // ignore malformed lines } } } } } -