diff --git a/Bin/system-stats.sh b/Bin/system-stats.sh index 7bd1170..da966df 100755 --- a/Bin/system-stats.sh +++ b/Bin/system-stats.sh @@ -28,7 +28,7 @@ TEMP_SENSOR_TYPE="" # --- Data Collection Functions --- # -# Gets memory usage in GB and as a percentage. +# Gets memory usage in GB, MB, and as a percentage. # get_memory_info() { awk ' @@ -39,11 +39,10 @@ get_memory_info() { usage_kb = total - available usage_gb = usage_kb / 1000000 usage_percent = (usage_kb / total) * 100 - # MODIFIED: Round the memory percentage to the nearest integer. printf "%.1f %.0f\n", usage_gb, usage_percent } else { # Fallback if /proc/meminfo is unreadable or empty. - print "0.0 0.0" + print "0.0 0 0" } } ' /proc/meminfo @@ -95,10 +94,8 @@ get_cpu_usage() { if (total > 0) { # Formula: 100 * (Total - Idle) / Total usage = 100 * (total - idle) / total - # MODIFIED: Changed format from "%.2f" back to "%.1f" for one decimal place. printf "%.1f\n", usage } else { - # MODIFIED: Changed output back to "0.0" to match the precision. print "0.0" } }' @@ -171,7 +168,7 @@ get_cpu_temp() { # This loop runs indefinitely, gathering and printing stats. while true; do # Call the functions to gather all the data. - # 'read' is used to capture the two output values from get_memory_info. + # get_memory_info read -r mem_gb mem_per <<< "$(get_memory_info)" # Command substitution captures the single output from the other functions. @@ -179,11 +176,11 @@ while true; do cpu_usage=$(get_cpu_usage) cpu_temp=$(get_cpu_temp) - # Use printf to format the final JSON output string, matching the Zig program. - printf '{"mem":"%s", "cpu": "%s", "cputemp": "%s", "memper": "%s", "diskper": "%s"}\n' \ - "$mem_gb" \ + # Use printf to format the final JSON output string, adding the mem_mb key. + printf '{"cpu": "%s", "cputemp": "%s", "memgb":"%s", "memper": "%s", "diskper": "%s"}\n' \ "$cpu_usage" \ "$cpu_temp" \ + "$mem_gb" \ "$mem_per" \ "$disk_per" diff --git a/Modules/Bar/Bar.qml b/Modules/Bar/Bar.qml index a494664..3d4c79f 100644 --- a/Modules/Bar/Bar.qml +++ b/Modules/Bar/Bar.qml @@ -50,11 +50,14 @@ Variants { anchors.verticalCenter: parent.verticalCenter spacing: Style.marginSmall * scaling - NText { - text: screen.name - anchors.verticalCenter: parent.verticalCenter - font.weight: Style.fontWeightBold - } + // Debug show monitor name + // NText { + // text: screen.name + // anchors.verticalCenter: parent.verticalCenter + // font.weight: Style.fontWeightBold + // } + + SystemMonitor {} } // Center diff --git a/Modules/Bar/SystemMonitor.qml b/Modules/Bar/SystemMonitor.qml new file mode 100644 index 0000000..ccac84b --- /dev/null +++ b/Modules/Bar/SystemMonitor.qml @@ -0,0 +1,84 @@ +import QtQuick +import Quickshell +import qs.Services +import qs.Widgets + +Row { + id: layout + anchors.verticalCenter: parent.verticalCenter + spacing: Style.marginSmall * scaling + visible: Settings.data.bar.showSystemInfo + + // Ensure our width is an integer + width: Math.floor(cpuUsageLayout.width + cpuTempLayout.width + memoryUsageLayout.width + (2 * 10)) + + Row { + id: cpuUsageLayout + spacing: Style.marginTiny * scaling + + NText { + id: cpuUsageIcon + text: "speed" + font.family: "Material Symbols Outlined" + font.pointSize: Style.fontSizeLarge * scaling + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + color: Colors.accentPrimary + } + + NText { + id: cpuUsageText + text: `${SystemStats.cpuUsage}%` + font.pointSize: Style.fontSizeSmall * scaling + font.weight: Style.fontWeightBold + anchors.verticalCenter: parent.verticalCenter + verticalAlignment: Text.AlignVCenter + } + } + + // CPU Temperature Component + Row { + id: cpuTempLayout + spacing: Style.marginTiny * scaling + + NText { + text: "thermometer" + font.family: "Material Symbols Outlined" + font.pointSize: Style.fontSizeLarge * scaling + color: Colors.accentPrimary + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + } + + NText { + text: `${SystemStats.cpuTemp}°C` + font.pointSize: Style.fontSizeSmall * scaling + font.weight: Style.fontWeightBold + anchors.verticalCenter: parent.verticalCenter + verticalAlignment: Text.AlignVCenter + } + } + + // Memory Usage Component + Row { + id: memoryUsageLayout + spacing: Style.marginTiny * scaling + + NText { + text: "memory" + font.family: "Material Symbols Outlined" + font.pointSize: Style.fontSizeLarge * scaling + color: Colors.accentPrimary + verticalAlignment: Text.AlignVCenter + anchors.verticalCenter: parent.verticalCenter + } + + NText { + text: `${SystemStats.memoryUsageGb}G` + font.pointSize: Style.fontSizeSmall * scaling + font.weight: Style.fontWeightBold + anchors.verticalCenter: parent.verticalCenter + verticalAlignment: Text.AlignVCenter + } + } +} diff --git a/Services/SystemStats.qml b/Services/SystemStats.qml index add1e38..4c9d3b0 100644 --- a/Services/SystemStats.qml +++ b/Services/SystemStats.qml @@ -11,6 +11,7 @@ Singleton { // Public values property real cpuUsage: 0 property real cpuTemp: 0 + property real memoryUsageGb: 0 property real memoryUsagePer: 0 property real diskUsage: 0 @@ -25,6 +26,7 @@ Singleton { const data = JSON.parse(line) root.cpuUsage = data.cpu root.cpuTemp = data.cputemp + root.memoryUsageGb = data.memgb root.memoryUsagePer = data.memper root.diskUsage = data.diskper } catch (e) {