using initialTitle instead of currentTitle
This commit is contained in:
@@ -1,9 +0,0 @@
|
|||||||
pragma Singleton
|
|
||||||
|
|
||||||
import Quickshell
|
|
||||||
import Quickshell.Hyprland
|
|
||||||
|
|
||||||
Singleton {
|
|
||||||
id: root
|
|
||||||
property string activeWindow: Hyprland.activeToplevel?.title || ""
|
|
||||||
}
|
|
||||||
@@ -14,6 +14,13 @@ Item {
|
|||||||
implicitHeight: 22
|
implicitHeight: 22
|
||||||
property bool warning: percentage * 100 >= warningThreshold
|
property bool warning: percentage * 100 >= warningThreshold
|
||||||
|
|
||||||
|
Behavior on percentage {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 300
|
||||||
|
easing.type: Easing.InOutQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: resourceRowLayout
|
id: resourceRowLayout
|
||||||
spacing: 2
|
spacing: 2
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ import QtQuick
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple polled resource usage service with RAM, Swap, and CPU usage.
|
|
||||||
*/
|
|
||||||
Singleton {
|
Singleton {
|
||||||
property double memoryTotal: 1
|
property double memoryTotal: 1
|
||||||
property double memoryFree: 1
|
property double memoryFree: 1
|
||||||
@@ -22,6 +19,7 @@ Singleton {
|
|||||||
property double gpuUsage: 0
|
property double gpuUsage: 0
|
||||||
property double gpuMemUsage: 0
|
property double gpuMemUsage: 0
|
||||||
property double totalMem: 0
|
property double totalMem: 0
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
interval: 1
|
interval: 1
|
||||||
running: true
|
running: true
|
||||||
@@ -70,6 +68,7 @@ Singleton {
|
|||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: {
|
onStreamFinished: {
|
||||||
totalMem = Number(this.text.trim())
|
totalMem = Number(this.text.trim())
|
||||||
|
oneshotMem.running = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ Item {
|
|||||||
|
|
||||||
Resource {
|
Resource {
|
||||||
percentage: ResourceUsage.memoryUsedPercentage
|
percentage: ResourceUsage.memoryUsedPercentage
|
||||||
|
warningThreshold: 95
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
@@ -41,13 +42,14 @@ Item {
|
|||||||
|
|
||||||
Resource {
|
Resource {
|
||||||
percentage: ResourceUsage.cpuUsage
|
percentage: ResourceUsage.cpuUsage
|
||||||
|
warningThreshold: 80
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
font.family: "Material Symbols Rounded"
|
font.family: "Material Symbols Rounded"
|
||||||
font.pixelSize: 18
|
font.pixelSize: 16
|
||||||
text: "\ue30d"
|
text: ""
|
||||||
color: "#ffffff"
|
color: "#ffffff"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+22
-1
@@ -1,15 +1,36 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import Quickshell.Io
|
||||||
|
import Quickshell.Hyprland
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
property string currentTitle
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.preferredWidth: Math.max( titleText1.implicitWidth, titleText2.implicitWidth ) + 10
|
Layout.preferredWidth: Math.max( titleText1.implicitWidth, titleText2.implicitWidth ) + 10
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
property string currentTitle: ActiveWindow.activeWindow
|
|
||||||
property bool showFirst: true
|
property bool showFirst: true
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: initialTitleProc
|
||||||
|
command: ["./scripts/initialTitle.sh"]
|
||||||
|
running: false
|
||||||
|
stdout: StdioCollector {
|
||||||
|
onStreamFinished: {
|
||||||
|
root.currentTitle = this.text.trim().replace(/\"/g, "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
Hyprland.rawEvent.connect(( event ) => {
|
||||||
|
if (event.name === "activewindow") {
|
||||||
|
initialTitleProc.running = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
onCurrentTitleChanged: {
|
onCurrentTitleChanged: {
|
||||||
if (showFirst) {
|
if (showFirst) {
|
||||||
titleText2.text = currentTitle
|
titleText2.text = currentTitle
|
||||||
|
|||||||
Executable
+17
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/zsh
|
||||||
|
|
||||||
|
raw="$(hyprctl activewindow)"
|
||||||
|
|
||||||
|
json="$(echo "$raw" | jq -Rn '
|
||||||
|
[ inputs
|
||||||
|
| sub("\r$"; "")
|
||||||
|
| select(test(":"))
|
||||||
|
| capture("^(?<key>[^:]+):[ \t]*(?<value>.*)$")
|
||||||
|
| .key |= ltrim
|
||||||
|
]
|
||||||
|
| from_entries
|
||||||
|
')"
|
||||||
|
|
||||||
|
title="$(echo "$json" | jq '.initialTitle')"
|
||||||
|
|
||||||
|
echo "$title"
|
||||||
Reference in New Issue
Block a user