added a systeminfo module to quickshell

This commit is contained in:
Tomas Rivera
2026-03-11 16:58:03 +01:00
parent a8568872bf
commit 587eb6179e
5 changed files with 128 additions and 69 deletions
+91 -69
View File
@@ -3,6 +3,7 @@ import QtQuick.Effects
import Quickshell
import QtQuick.Layouts
import Quickshell.Wayland
import Quickshell.Io
import "mpris" as Mpris
import "systray" as SysTray
import "../theme" as Theme
@@ -14,23 +15,24 @@ PanelWindow {
property var modelData
readonly property var tooltip: tooltip
readonly property real tooltipYOffset: root.height + 2
Tooltip {
id: tooltip
bar: root
}
function boundedY(targetY: real, height: real): real {
return Math.max(bar.anchors.topMargin + height, Math.min(bar.height + bar.anchors.topMargin - height, targetY));
return Math.max(bar.anchors.topMargin + height,
Math.min(bar.height + bar.anchors.topMargin - height, targetY));
}
function boundedX(targetX: real, width: real): real {
return Math.max(bar.anchors.leftMargin + width, Math.min(bar.width + bar.anchors.leftMargin - width, targetX));
return Math.max(bar.anchors.leftMargin + width,
Math.min(bar.width + bar.anchors.leftMargin - width, targetX));
}
WlrLayershell.namespace: "shell:bar"
anchors {
top: true
left: true
right: true
}
anchors { top: true; left: true; right: true }
exclusiveZone: 48
implicitHeight: 72
color: Theme.Colors.barColor1
@@ -44,25 +46,16 @@ PanelWindow {
Item {
id: bar
anchors {
top: parent.top
left: parent.left
right: parent.right
}
anchors { top: parent.top; left: parent.left; right: parent.right }
implicitHeight: 48
// ---------------- LEFT MODULE ----------------
Rectangle {
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
}
implicitWidth: left.width + left.anchors.leftMargin + left.anchors.rightMargin
implicitHeight: left.height
id: leftModule
anchors { top: parent.top; bottom: parent.bottom; left: parent.left }
color: Theme.Colors.barColor2
implicitWidth: left.childrenRect.width + 14
implicitHeight: left.childrenRect.height + 8
Rectangle {
z: -1
@@ -70,6 +63,7 @@ PanelWindow {
color: Theme.Colors.barColor3
anchors.margins: -4
}
Image {
width: 16 * 6
height: 4 * 6
@@ -81,39 +75,87 @@ PanelWindow {
RowLayout {
id: left
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
leftMargin: 7
rightMargin: 7
}
anchors { top: parent.top; bottom: parent.bottom; left: parent.left; leftMargin: 7; rightMargin: 7 }
spacing: 12
//Launcher {}
Workspaces { bar: root }
SysTray.SysTray { bar: root }
}
}
Workspaces {
bar: root
// ---------------- SYSINFO MODULE ----------------
Rectangle {
id: leftCenterModule
anchors { top: parent.top; bottom: parent.bottom; left: leftModule.right; leftMargin: 30 }
color: Theme.Colors.barColor6
implicitWidth: sysinfo.childrenRect.width + 16
implicitHeight: sysinfo.childrenRect.height + 8
Rectangle {
z: -1
anchors.fill: parent
color: Theme.Colors.barColor7
anchors.margins: -4
}
Image {
width: 16 * 6
height: 4 * 6
anchors.top: parent.bottom
anchors.left: parent.left
source: "../assets/bar-decor.png"
smooth: false
}
RowLayout {
id: sysinfo
spacing: 10
property int cpu: 0
property int mem: 0
property int disk: 0
property real power: 0
Timer {
interval: 2000
running: true
repeat: true
onTriggered: sysProcess.running = true
}
SysTray.SysTray {
bar: root
Process {
id: sysProcess
command: ["QS-sysinfo"]
stdout: SplitParser {
onRead: function(line) {
try {
var data = JSON.parse(line)
sysinfo.cpu = data.cpu
sysinfo.mem = data.mem
sysinfo.disk = data.disk
sysinfo.power = data.power
} catch(e) {}
}
}
}
Text {
id: infoText
text: "CPU " + sysinfo.cpu + "% MEM " + sysinfo.mem + "% DSK " + sysinfo.disk + "% PWR " + sysinfo.power + "W"
font.pixelSize: 18
color: Theme.Colors.barColor8
}
}
}
// ---------------- RIGHT MODULE ----------------
Rectangle {
anchors {
top: parent.top
bottom: parent.bottom
right: parent.right
}
implicitWidth: right.width + right.anchors.leftMargin + right.anchors.rightMargin
implicitHeight: right.height
id: rightCenterModule
anchors { top: parent.top; bottom: parent.bottom; right: parent.right }
color: Theme.Colors.barColor4
implicitWidth: right.childrenRect.width + 14
implicitHeight: right.childrenRect.height + 8
Rectangle {
z: -1
@@ -121,6 +163,7 @@ PanelWindow {
color: Theme.Colors.barColor5
anchors.margins: -4
}
Image {
width: 16 * 6
height: 4 * 6
@@ -133,34 +176,13 @@ PanelWindow {
RowLayout {
id: right
anchors {
top: parent.top
bottom: parent.bottom
right: parent.right
leftMargin: 7
rightMargin: 7
}
anchors { top: parent.top; bottom: parent.bottom; right: parent.right; leftMargin: 7; rightMargin: 7 }
spacing: 12
Time {}
Volume {
bar: root
}
Mpris.Players {
window: root
bar: root
}
//Theme {}
Power {
id: power
bar: root
}
Volume { bar: root }
Mpris.Players { window: root; bar: root }
Power { id: power; bar: root }
}
}
}
+3
View File
@@ -51,6 +51,9 @@ QtObject {
readonly property color barColor3: border // Left block bar border original color: "#BE850E"
readonly property color barColor4: background // Right block bar background original color: "#3B253F"
readonly property color barColor5: border // Right block bar border original color: "#BE850E"
readonly property color barColor6: background // left center block bar background
readonly property color barColor7: border // left center block bar border
readonly property color barColor8: text // left center block bar text color
readonly property color powerColor1: black // Battery indicator empty color original color: "black"
readonly property color powerColor2: red // original color: "red"
readonly property color powerColor3: accentYellow // Battery indicator normal color original color: "#EEA939"