From 35d2addd70c1f86e620b2ae7de5e9e7a8dc95213 Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Thu, 24 Jul 2025 11:22:18 -0400 Subject: [PATCH] gpu temp/usage --- config/Dimensions.qml | 9 +++++ constants/Icons.qml | 1 + modules/bar/Bar.qml | 4 +++ modules/bar/components/Gpu.qml | 65 ++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 modules/bar/components/Gpu.qml diff --git a/config/Dimensions.qml b/config/Dimensions.qml index fb64b16..0ab6893 100644 --- a/config/Dimensions.qml +++ b/config/Dimensions.qml @@ -15,6 +15,7 @@ Singleton { property Storage storage: Storage {} property Memory memory: Memory {} property Cpu cpu: Cpu {} + property Gpu gpu: Gpu {} property Caffeine caffeine: Caffeine {} property Workspace workspace: Workspace {} property Tray tray: Tray {} @@ -73,6 +74,14 @@ Singleton { property int height: 30 property int horizontalPadding: 8 property int verticalPadding: 6 + } + + component Gpu: QtObject { + property int iconSize: 14 + property int fontSize: 14 + property int height: 30 + property int horizontalPadding: 8 + property int verticalPadding: 6 } component Caffeine: QtObject { diff --git a/constants/Icons.qml b/constants/Icons.qml index 5b817f5..9eebe1c 100644 --- a/constants/Icons.qml +++ b/constants/Icons.qml @@ -6,6 +6,7 @@ Singleton { property string brickWall: "\u{E586}" property string coffee: "\u{E09a}" property string cpu: "\u{E0ad}" + property string gpu: "\u{E66f}" property string hardDrive: "\u{E0f1}" property string memoryStick: "\u{E44a}" property string triangle: "\u{E192}" diff --git a/modules/bar/Bar.qml b/modules/bar/Bar.qml index c1ac9f2..f16330a 100644 --- a/modules/bar/Bar.qml +++ b/modules/bar/Bar.qml @@ -114,6 +114,10 @@ Scope { Cpu { anchors.verticalCenter: parent.verticalCenter + } + + Gpu { + anchors.verticalCenter: parent.verticalCenter } Clock { diff --git a/modules/bar/components/Gpu.qml b/modules/bar/components/Gpu.qml new file mode 100644 index 0000000..be1d799 --- /dev/null +++ b/modules/bar/components/Gpu.qml @@ -0,0 +1,65 @@ +import QtQuick +import Quickshell +import "../../../config/" +import "../../../constants/" +import "../../../services/" +import "../../../styled/" +import "../../../utils/" + +Clickable { + id: root + + property bool showTemp: false + + implicitWidth: row.width + implicitHeight: Dimensions.gpu.height + + Ref { + service: SystemInfo + } + + onClicked: { + root.showTemp = !root.showTemp; + } + + Row { + id: row + StyledText { + id: icon + + font.family: Theme.lucide.font.family + font.pixelSize: Dimensions.gpu.iconSize + font.bold: true + text: Icons.gpu + + anchors.verticalCenter: parent.verticalCenter + topPadding: Dimensions.gpu.verticalPadding + bottomPadding: Dimensions.gpu.verticalPadding + leftPadding: Dimensions.gpu.horizontalPadding + } + + StyledText { + id: text + anchors.verticalCenter: parent.verticalCenter + topPadding: Dimensions.gpu.verticalPadding + bottomPadding: Dimensions.gpu.verticalPadding + rightPadding: Dimensions.gpu.horizontalPadding + + font.pixelSize: Dimensions.gpu.fontSize + + text: ` ${(SystemInfo.gpuPerc * 100).toFixed()}%` + + states: [ + State { + name: "temp" + when: root.showTemp + PropertyChanges { + text { + text: ` ${(SystemInfo.gpuTemp)}℃` + } + } + } + ] + } + } +}