diff --git a/Modules/ActiveWindow.qml b/Modules/ActiveWindow.qml deleted file mode 100644 index e942be7..0000000 --- a/Modules/ActiveWindow.qml +++ /dev/null @@ -1,9 +0,0 @@ -pragma Singleton - -import Quickshell -import Quickshell.Hyprland - -Singleton { - id: root - property string activeWindow: Hyprland.activeToplevel?.title || "" -} diff --git a/Modules/Resource.qml b/Modules/Resource.qml index 5127edf..432d5ce 100644 --- a/Modules/Resource.qml +++ b/Modules/Resource.qml @@ -14,6 +14,13 @@ Item { implicitHeight: 22 property bool warning: percentage * 100 >= warningThreshold + Behavior on percentage { + NumberAnimation { + duration: 300 + easing.type: Easing.InOutQuad + } + } + RowLayout { id: resourceRowLayout spacing: 2 diff --git a/Modules/ResourceUsage.qml b/Modules/ResourceUsage.qml index b91ef9e..d2909af 100644 --- a/Modules/ResourceUsage.qml +++ b/Modules/ResourceUsage.qml @@ -5,9 +5,6 @@ import QtQuick import Quickshell import Quickshell.Io -/** - * Simple polled resource usage service with RAM, Swap, and CPU usage. - */ Singleton { property double memoryTotal: 1 property double memoryFree: 1 @@ -22,6 +19,7 @@ Singleton { property double gpuUsage: 0 property double gpuMemUsage: 0 property double totalMem: 0 + Timer { interval: 1 running: true @@ -70,6 +68,7 @@ Singleton { stdout: StdioCollector { onStreamFinished: { totalMem = Number(this.text.trim()) + oneshotMem.running = false } } } diff --git a/Modules/Resources.qml b/Modules/Resources.qml index 5c908ef..0b2a74c 100644 --- a/Modules/Resources.qml +++ b/Modules/Resources.qml @@ -29,6 +29,7 @@ Item { Resource { percentage: ResourceUsage.memoryUsedPercentage + warningThreshold: 95 } Text { @@ -41,13 +42,14 @@ Item { Resource { percentage: ResourceUsage.cpuUsage + warningThreshold: 80 } Text { Layout.alignment: Qt.AlignVCenter font.family: "Material Symbols Rounded" - font.pixelSize: 18 - text: "\ue30d" + font.pixelSize: 16 + text: "󰢮" color: "#ffffff" } diff --git a/Modules/WindowTitle.qml b/Modules/WindowTitle.qml index e3b079d..8e3ddc4 100644 --- a/Modules/WindowTitle.qml +++ b/Modules/WindowTitle.qml @@ -1,15 +1,36 @@ import QtQuick import QtQuick.Layouts +import Quickshell.Io +import Quickshell.Hyprland Item { id: root + property string currentTitle Layout.fillHeight: true Layout.preferredWidth: Math.max( titleText1.implicitWidth, titleText2.implicitWidth ) + 10 clip: true - property string currentTitle: ActiveWindow.activeWindow 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: { if (showFirst) { titleText2.text = currentTitle diff --git a/scripts/initialTitle.sh b/scripts/initialTitle.sh new file mode 100755 index 0000000..33bfaea --- /dev/null +++ b/scripts/initialTitle.sh @@ -0,0 +1,17 @@ +#!/bin/zsh + +raw="$(hyprctl activewindow)" + +json="$(echo "$raw" | jq -Rn ' + [ inputs + | sub("\r$"; "") + | select(test(":")) + | capture("^(?[^:]+):[ \t]*(?.*)$") + | .key |= ltrim + ] + | from_entries +')" + +title="$(echo "$json" | jq '.initialTitle')" + +echo "$title"