Code formatting

This commit is contained in:
quadbyte 2025-08-10 13:26:46 -04:00
parent c62e199ea7
commit 1d13bbe0f7
11 changed files with 161 additions and 85 deletions

View file

@ -22,7 +22,9 @@ NBox {
anchors.margins: Style.marginXL * scaling anchors.margins: Style.marginXL * scaling
spacing: Style.marginSmall * scaling spacing: Style.marginSmall * scaling
Item { height: 36 * scaling } Item {
height: 36 * scaling
}
Text { Text {
text: "music_note" text: "music_note"
@ -38,7 +40,8 @@ NBox {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
} }
Item { height: 36 * scaling } Item {
height: 36 * scaling
}
} }
} }

View file

@ -52,17 +52,29 @@ NBox {
ColumnLayout { ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
spacing: 2 * scaling spacing: 2 * scaling
NText { text: Quickshell.env("USER") || "user" } NText {
NText { text: "System Uptime: —"; color: Colors.textSecondary } text: Quickshell.env("USER") || "user"
}
NText {
text: "System Uptime: —"
color: Colors.textSecondary
}
} }
RowLayout { RowLayout {
spacing: Style.marginSmall * scaling spacing: Style.marginSmall * scaling
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
Item { Layout.fillWidth: true } Item {
NIconButton { icon: "settings"; sizeMultiplier: 0.8 } Layout.fillWidth: true
NIconButton { icon: "power_settings_new"; sizeMultiplier: 0.8 } }
NIconButton {
icon: "settings"
sizeMultiplier: 0.8
}
NIconButton {
icon: "power_settings_new"
sizeMultiplier: 0.8
}
} }
} }
} }

View file

@ -6,7 +6,6 @@ import Quickshell.Wayland
import qs.Services import qs.Services
import qs.Widgets import qs.Widgets
NLoader { NLoader {
id: root id: root
@ -46,7 +45,6 @@ NLoader {
Component.onCompleted: show() Component.onCompleted: show()
// Inline helpers moved to dedicated widgets: NCard and NCircleStat // Inline helpers moved to dedicated widgets: NCard and NCircleStat
Rectangle { Rectangle {
id: panelBackground id: panelBackground
color: Colors.backgroundPrimary color: Colors.backgroundPrimary
@ -61,13 +59,14 @@ NLoader {
// Place the panel just below the bar (overlay content starts below bar due to topMargin) // Place the panel just below the bar (overlay content starts below bar due to topMargin)
y: Style.marginSmall * scaling y: Style.marginSmall * scaling
// Center horizontally under the anchorX, clamped to the screen bounds // Center horizontally under the anchorX, clamped to the screen bounds
x: Math.max( x: Math.max(Style.marginSmall * scaling, Math.min(
Style.marginSmall * scaling, parent.width - width - Style.marginSmall * scaling,
Math.min(parent.width - width - Style.marginSmall * scaling,
Math.round(anchorX - width / 2))) Math.round(anchorX - width / 2)))
// Prevent closing when clicking in the panel bg // Prevent closing when clicking in the panel bg
MouseArea { anchors.fill: parent } MouseArea {
anchors.fill: parent
}
// Content wrapper to ensure childrenRect drives implicit height // Content wrapper to ensure childrenRect drives implicit height
Item { Item {
@ -88,8 +87,14 @@ NLoader {
spacing: sidePanel.cardSpacing spacing: sidePanel.cardSpacing
// Cards (consistent inter-card spacing via ColumnLayout spacing) // Cards (consistent inter-card spacing via ColumnLayout spacing)
ProfileCard { Layout.topMargin: 0; Layout.bottomMargin: 0 } ProfileCard {
WeatherCard { Layout.topMargin: 0; Layout.bottomMargin: 0 } Layout.topMargin: 0
Layout.bottomMargin: 0
}
WeatherCard {
Layout.topMargin: 0
Layout.bottomMargin: 0
}
// Middle section: media + stats column // Middle section: media + stats column
RowLayout { RowLayout {
@ -99,10 +104,16 @@ NLoader {
spacing: sidePanel.cardSpacing spacing: sidePanel.cardSpacing
// Media card // 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 // System monitors combined in one card
SystemCard { id: statsCard } SystemCard {
id: statsCard
}
} }
// Bottom actions (two grouped rows of round buttons) // Bottom actions (two grouped rows of round buttons)
@ -122,7 +133,9 @@ NLoader {
anchors.fill: parent anchors.fill: parent
anchors.margins: Style.marginSmall * scaling anchors.margins: Style.marginSmall * scaling
spacing: sidePanel.cardSpacing spacing: sidePanel.cardSpacing
Item { Layout.fillWidth: true } Item {
Layout.fillWidth: true
}
// Performance // Performance
NIconButton { NIconButton {
icon: "speed" icon: "speed"
@ -141,7 +154,9 @@ NLoader {
sizeMultiplier: 1.0 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.fill: parent
anchors.margins: Style.marginSmall * scaling anchors.margins: Style.marginSmall * scaling
spacing: sidePanel.cardSpacing spacing: sidePanel.cardSpacing
Item { Layout.fillWidth: true } Item {
Layout.fillWidth: true
}
// Record // Record
NIconButton { icon: "fiber_manual_record"; sizeMultiplier: 1.0 } NIconButton {
icon: "fiber_manual_record"
sizeMultiplier: 1.0
}
// Wallpaper // Wallpaper
NIconButton { icon: "image"; sizeMultiplier: 1.0 } NIconButton {
Item { Layout.fillWidth: true } icon: "image"
sizeMultiplier: 1.0
}
Item {
Layout.fillWidth: true
}
} }
} }
} }

View file

@ -24,17 +24,52 @@ NBox {
spacing: Style.marginSmall * scaling spacing: Style.marginSmall * scaling
// Slight top padding // 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 {
NCircleStat { value: sysMon.cpuTemp || SysInfo.cpuTemp; suffix: "°C"; icon: "device_thermostat"; flat: true; contentScale: 0.8; width: 72 * scaling; height: 68 * scaling } value: sysMon.cpuUsage || SysInfo.cpuUsage
NCircleStat { value: sysMon.memoryUsagePer || SysInfo.memoryUsagePer; icon: "memory"; flat: true; contentScale: 0.8; width: 72 * scaling; height: 68 * scaling } icon: "speed"
NCircleStat { value: sysMon.diskUsage || SysInfo.diskUsage; icon: "data_usage"; flat: true; contentScale: 0.8; width: 72 * scaling; height: 68 * scaling } 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 // Extra bottom padding to shift the perceived stack slightly upward
Item { height: Style.marginMedium * scaling } Item {
height: Style.marginMedium * scaling
}
} }
} }

View file

@ -30,12 +30,21 @@ NBox {
color: Colors.accentSecondary color: Colors.accentSecondary
} }
ColumnLayout { ColumnLayout {
NText { text: "Dinslaken (GMT+2)" } NText {
NText { text: "26°C"; font.pointSize: (Style.fontSizeXL + 6) * scaling } 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 { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
@ -44,16 +53,20 @@ NBox {
model: 5 model: 5
delegate: ColumnLayout { delegate: ColumnLayout {
spacing: 2 * scaling spacing: 2 * scaling
NText { text: ["Sun","Mon","Tue","Wed","Thu"][index] } NText {
text: ["Sun", "Mon", "Tue", "Wed", "Thu"][index]
}
Text { Text {
text: index % 2 === 0 ? "wb_sunny" : "cloud" text: index % 2 === 0 ? "wb_sunny" : "cloud"
font.family: "Material Symbols Outlined" font.family: "Material Symbols Outlined"
color: Colors.textSecondary color: Colors.textSecondary
} }
NText { text: "26° / 14°"; color: Colors.textSecondary } NText {
text: "26° / 14°"
color: Colors.textSecondary
}
} }
} }
} }
} }
} }

View file

@ -23,7 +23,9 @@ Singleton {
const clamped = Math.max(0.6, Math.min(1.8, overrideScale)) const clamped = Math.max(0.6, Math.min(1.8, overrideScale))
return clamped return clamped
} }
} catch (e) {} } catch (e) {
}
if (typeof aScreen !== 'undefined' & aScreen) { if (typeof aScreen !== 'undefined' & aScreen) {

View file

@ -18,7 +18,6 @@ Singleton {
// Needed to only have one NPanel loaded at a time. // Needed to only have one NPanel loaded at a time.
// property var openPanel: null // property var openPanel: null
Item { Item {
Component.onCompleted: { Component.onCompleted: {
// ensure settings dir // ensure settings dir

View file

@ -17,4 +17,3 @@ Rectangle {
border.width: Math.min(1, Style.borderThin * scaling) border.width: Math.min(1, Style.borderThin * scaling)
clip: true clip: true
} }

View file

@ -15,4 +15,3 @@ Rectangle {
border.color: Colors.backgroundTertiary border.color: Colors.backgroundTertiary
border.width: Math.min(1, Style.borderThin * scaling) border.width: Math.min(1, Style.borderThin * scaling)
} }

View file

@ -109,4 +109,3 @@ Rectangle {
} }
} }
} }

View file

@ -21,39 +21,29 @@ Item {
Process { Process {
id: reader id: reader
running: true running: true
command: [ command: ["sh", "-c", // Outputs: {"cpu":<int>,"memper":<int>,"cputemp":<int>}
"sh", "-c", "interval=" + intervalSeconds + "; " + "while true; do " + // First /proc/stat snapshot
// Outputs: {"cpu":<int>,"memper":<int>,"cputemp":<int>} "read _ u1 n1 s1 id1 iw1 ir1 si1 st1 gs1 < /proc/stat; "
"interval=" + intervalSeconds + "; " + + "t1=$((u1+n1+s1+id1+iw1+ir1+si1+st1)); i1=$((id1+iw1)); "
"while true; do " + + "sleep $interval; " + // Second /proc/stat snapshot
// First /proc/stat snapshot "read _ u2 n2 s2 id2 iw2 ir2 si2 st2 gs2 < /proc/stat; "
"read _ u1 n1 s1 id1 iw1 ir1 si1 st1 gs1 < /proc/stat; " + + "t2=$((u2+n2+s2+id2+iw2+ir2+si2+st2)); i2=$((id2+iw2)); "
"t1=$((u1+n1+s1+id1+iw1+ir1+si1+st1)); i1=$((id1+iw1)); " + + "dt=$((t2 - t1)); di=$((i2 - i1)); " + "cpu=$(( (100*(dt - di)) / (dt>0?dt:1) )); "
"sleep $interval; " + + // Memory percent via /proc/meminfo (kB)
// Second /proc/stat snapshot "mt=$(awk '/MemTotal/ {print $2}' /proc/meminfo); "
"read _ u2 n2 s2 id2 iw2 ir2 si2 st2 gs2 < /proc/stat; " + + "ma=$(awk '/MemAvailable/ {print $2}' /proc/meminfo); "
"t2=$((u2+n2+s2+id2+iw2+ir2+si2+st2)); i2=$((id2+iw2)); " + + "mm=$((mt - ma)); mp=$(( (100*mm) / (mt>0?mt:1) )); "
"dt=$((t2 - t1)); di=$((i2 - i1)); " + + // Temperature: scan hwmon and thermal zones, choose max; convert m°C °C
"cpu=$(( (100*(dt - di)) / (dt>0?dt:1) )); " + "ct=0; "
// Memory percent via /proc/meminfo (kB) + "for f in /sys/class/hwmon/hwmon*/temp*_input /sys/class/thermal/thermal_zone*/temp; do "
"mt=$(awk '/MemTotal/ {print $2}' /proc/meminfo); " + + "[ -r \"$f\" ] || continue; v=$(cat \"$f\" 2>/dev/null); " + "[ -z \"$v\" ] && continue; "
"ma=$(awk '/MemAvailable/ {print $2}' /proc/meminfo); " + + "if [ \"$v\" -gt 1000 ] 2>/dev/null; then v=$((v/1000)); fi; "
"mm=$((mt - ma)); mp=$(( (100*mm) / (mt>0?mt:1) )); " + + "[ \"$v\" -gt \"$ct\" ] 2>/dev/null && ct=$v; " + "done; "
// Temperature: scan hwmon and thermal zones, choose max; convert m°C °C + // Disk usage percent for root filesystem
"ct=0; " + "dp=$(df -P / 2>/dev/null | awk 'NR==2{gsub(/%/,\"\",$5); print $5}'); "
"for f in /sys/class/hwmon/hwmon*/temp*_input /sys/class/thermal/thermal_zone*/temp; do " + + "[ -z \"$dp\" ] && dp=0; " + // Emit JSON line
"[ -r \"$f\" ] || continue; v=$(cat \"$f\" 2>/dev/null); " + "echo \"{\\\"cpu\\\":$cpu,\\\"memper\\\":$mp,\\\"cputemp\\\":$ct,\\\"diskper\\\":$dp}\"; "
"[ -z \"$v\" ] && continue; " + + "done"]
"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 { stdout: SplitParser {
onRead: function (line) { onRead: function (line) {
@ -64,10 +54,10 @@ Item {
root.memoryUsagePer = +data.memper root.memoryUsagePer = +data.memper
root.diskUsage = +data.diskper root.diskUsage = +data.diskper
} catch (e) { } catch (e) {
// ignore malformed lines // ignore malformed lines
} }
} }
} }
} }
} }