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
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
}
}
}

View file

@ -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
}
}
}
}

View file

@ -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)
@ -122,7 +133,9 @@ NLoader {
anchors.fill: parent
anchors.margins: Style.marginSmall * scaling
spacing: sidePanel.cardSpacing
Item { Layout.fillWidth: true }
Item {
Layout.fillWidth: true
}
// Performance
NIconButton {
icon: "speed"
@ -141,7 +154,9 @@ NLoader {
sizeMultiplier: 1.0
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
}
}
}
}

View file

@ -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
}
}
}

View file

@ -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
}
}
}
}
}
}

View file

@ -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) {

View file

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

View file

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

View file

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

View file

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

View file

@ -21,39 +21,29 @@ Item {
Process {
id: reader
running: true
command: [
"sh", "-c",
// Outputs: {"cpu":<int>,"memper":<int>,"cputemp":<int>}
"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":<int>,"memper":<int>,"cputemp":<int>}
"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
}
}
}
}
}