From bcd6b3c595bedfc9082b0fe071ffb8fc24adac9d Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Thu, 24 Jul 2025 11:08:40 -0400 Subject: [PATCH] memory usage --- config/Dimensions.qml | 27 ++++++------------- constants/Icons.qml | 1 + modules/bar/Bar.qml | 4 +++ modules/bar/components/Memory.qml | 44 +++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 modules/bar/components/Memory.qml diff --git a/config/Dimensions.qml b/config/Dimensions.qml index 9c5c094..fb64b16 100644 --- a/config/Dimensions.qml +++ b/config/Dimensions.qml @@ -13,6 +13,7 @@ Singleton { property Clock clock: Clock {} property Pipewire pipewire: Pipewire {} property Storage storage: Storage {} + property Memory memory: Memory {} property Cpu cpu: Cpu {} property Caffeine caffeine: Caffeine {} property Workspace workspace: Workspace {} @@ -20,8 +21,6 @@ Singleton { property TrayMenu trayMenu: TrayMenu {} component Bar: QtObject { - id: bar - property int spacing: 8 property int border: 2 property int height: 50 @@ -32,8 +31,6 @@ Singleton { } component Mpris: QtObject { - id: clock - property int fontSize: 14 property int height: 30 property int horizontalPadding: 8 @@ -41,8 +38,6 @@ Singleton { } component Clock: QtObject { - id: clock - property int fontSize: 14 property int height: 30 property int horizontalPadding: 8 @@ -50,8 +45,6 @@ Singleton { } component Pipewire: QtObject { - id: clock - property int fontSize: 14 property int height: 30 property int horizontalPadding: 8 @@ -59,8 +52,14 @@ Singleton { } component Storage: QtObject { - id: clock + property int iconSize: 14 + property int fontSize: 14 + property int height: 30 + property int horizontalPadding: 8 + property int verticalPadding: 6 + } + component Memory: QtObject { property int iconSize: 14 property int fontSize: 14 property int height: 30 @@ -69,8 +68,6 @@ Singleton { } component Cpu: QtObject { - id: clock - property int iconSize: 14 property int fontSize: 14 property int height: 30 @@ -79,8 +76,6 @@ Singleton { } component Caffeine: QtObject { - id: clock - property int fontSize: 16 property int height: 30 property int horizontalPadding: 8 @@ -88,8 +83,6 @@ Singleton { } component Workspace: QtObject { - id: workspace - property int spacing: 5 property int iconSize: 16 property int width: 30 @@ -99,8 +92,6 @@ Singleton { } component Tray: QtObject { - id: tray - property int spacing: 5 property int iconSize: 18 property int width: 30 @@ -110,8 +101,6 @@ Singleton { } component TrayMenu: QtObject { - id: trayItem - property int fontSize: 10 property int width: 30 property int height: 30 diff --git a/constants/Icons.qml b/constants/Icons.qml index 22e6268..5b817f5 100644 --- a/constants/Icons.qml +++ b/constants/Icons.qml @@ -7,6 +7,7 @@ Singleton { property string coffee: "\u{E09a}" property string cpu: "\u{E0ad}" property string hardDrive: "\u{E0f1}" + property string memoryStick: "\u{E44a}" property string triangle: "\u{E192}" property string triangleDashed: "\u{E642}" } diff --git a/modules/bar/Bar.qml b/modules/bar/Bar.qml index db9ea4a..c1ac9f2 100644 --- a/modules/bar/Bar.qml +++ b/modules/bar/Bar.qml @@ -108,6 +108,10 @@ Scope { anchors.verticalCenter: parent.verticalCenter } + Memory { + anchors.verticalCenter: parent.verticalCenter + } + Cpu { anchors.verticalCenter: parent.verticalCenter } diff --git a/modules/bar/components/Memory.qml b/modules/bar/components/Memory.qml new file mode 100644 index 0000000..1454c40 --- /dev/null +++ b/modules/bar/components/Memory.qml @@ -0,0 +1,44 @@ +import QtQuick +import Quickshell +import "../../../config/" +import "../../../constants/" +import "../../../services/" +import "../../../styled/" +import "../../../utils/" + +StyledLabel { + implicitWidth: childrenRect.width + implicitHeight: Dimensions.memory.height + + Ref { + service: SystemInfo + } + + Row { + StyledText { + id: icon + + font.family: Theme.lucide.font.family + font.pixelSize: Dimensions.memory.iconSize + font.bold: true + text: Icons.memoryStick + + anchors.verticalCenter: parent.verticalCenter + topPadding: Dimensions.memory.verticalPadding + bottomPadding: Dimensions.memory.verticalPadding + leftPadding: Dimensions.memory.horizontalPadding + } + + StyledText { + id: text + anchors.verticalCenter: parent.verticalCenter + topPadding: Dimensions.memory.verticalPadding + bottomPadding: Dimensions.memory.verticalPadding + rightPadding: Dimensions.memory.horizontalPadding + + font.pixelSize: Dimensions.memory.fontSize + + text: ` ${(SystemInfo.memPerc * 100).toFixed()}%` + } + } +}