fix qt_qpa_platformtheme, add volume OSD, adjust CPU and memory display

This commit is contained in:
2026-08-08 20:21:48 -07:00
parent a0b1248d1e
commit a93def8e12
4 changed files with 128 additions and 21 deletions
+31 -20
View File
@@ -7,13 +7,14 @@ import QtQuick.Layouts
import Quickshell.Services.SystemTray
import Quickshell.DBusMenu
import Quickshell.Widgets
Scope {
id: root
property string time
property int cpuUsage: 0
property int memUsage: 0
property string memUsage: "0"
property var lastCpuIdle: 0
property var lastCpuTotal: 0
@@ -47,15 +48,15 @@ Scope {
Process {
id: memProc
command: ["sh", "-c", "free | grep Mem"]
command: ["sh", "-c", "free -m | grep Mem"]
stdout: SplitParser {
onRead: data => {
if (!data)
return;
var parts = data.trim().split(/\s+/);
var total = parseInt(parts[1]) || 1;
var used = parseInt(parts[2]) || 0;
memUsage = Math.round(100 * used / total);
var total = (parts[1] / 1000).toFixed(2) || 1;
var used = (parts[2] / 1000).toFixed(2) || 0;
memUsage = `${used} / ${total}`;
}
}
Component.onCompleted: running = true
@@ -92,10 +93,6 @@ Scope {
property string fontFamily: "Inter"
property int fontSize: 16
BackgroundEffect.blurRegion: Region {
item: barRoot.contentItem
}
anchors.bottom: true
anchors.left: true
anchors.right: true
@@ -120,8 +117,8 @@ Scope {
color: isActive ? barRoot.colRed : barRoot.colFg
font {
family: root.fontFamily
pixelSize: root.fontSize
family: barRoot.fontFamily
pixelSize: barRoot.fontSize
bold: true
}
@@ -141,8 +138,8 @@ Scope {
color: barRoot.colFg
font {
family: root.fontFamily
pixelSize: root.fontSize
family: barRoot.fontFamily
pixelSize: barRoot.fontSize
bold: true
}
text: timeStr
@@ -150,7 +147,7 @@ Scope {
MouseArea {
anchors.fill: parent
onClicked: {
clock.timeFmt = (clock.timeFmt === "h:mm:ss AP") ? "ddd, MMM d - h:mm:ss AP" : "h:mm:ss AP";
clock.timeFmt = (clock.timeFmt === "h:mm:ss AP") ? "dddd M/d/yyyy - h:mm:ss AP" : "h:mm:ss AP";
}
}
}
@@ -159,13 +156,18 @@ Scope {
Layout.fillWidth: true
}
IconImage {
implicitSize: 20
source: Quickshell.iconPath("device_cpu")
}
// CPU
Text {
text: "CPU: " + cpuUsage + "%"
text: `${cpuUsage}%`
color: barRoot.colFg
font {
family: root.fontFamily
pixelSize: root.fontSize
family: barRoot.fontFamily
pixelSize: barRoot.fontSize
bold: true
}
}
@@ -176,13 +178,18 @@ Scope {
color: root.colMuted
}
IconImage {
implicitSize: 20
source: Quickshell.iconPath("memory")
}
// Memory
Text {
text: "Mem: " + memUsage + "%"
text: `${memUsage} GB`
color: barRoot.colFg
font {
family: root.fontFamily
pixelSize: root.fontSize
family: barRoot.fontFamily
pixelSize: barRoot.fontSize
bold: true
}
}
@@ -204,6 +211,10 @@ Scope {
}
}
}
BackgroundEffect.blurRegion: Region {
item: barRoot.contentItem
}
}
}
}