aboutsummaryrefslogtreecommitdiffstats
path: root/config/quickshell/services/HyprlandData.qml
diff options
context:
space:
mode:
authorJa.KooLit <85185940+JaKooLit@users.noreply.github.com>2025-06-15 17:08:35 +0000
committerGitHub <noreply@github.com>2025-06-15 17:08:35 +0000
commit88abbee9fe56f2e2489f04a017daaf3cfdc97511 (patch)
treec229832f852a3e55b41addcfc675d3ceb3df2282 /config/quickshell/services/HyprlandData.qml
parent4cf0d0bd5930da76e60f6770de3ee97c10ca7024 (diff)
parentd46077fe5ac56afbd63dc1222e649f10435b05e2 (diff)
Merge pull request #737 from SherLock707/overviewV2_qs
Overview Widget v2: Migration from AGS to QuickShell
Diffstat (limited to 'config/quickshell/services/HyprlandData.qml')
-rw-r--r--config/quickshell/services/HyprlandData.qml69
1 files changed, 69 insertions, 0 deletions
diff --git a/config/quickshell/services/HyprlandData.qml b/config/quickshell/services/HyprlandData.qml
new file mode 100644
index 00000000..2b88ad9c
--- /dev/null
+++ b/config/quickshell/services/HyprlandData.qml
@@ -0,0 +1,69 @@
+pragma Singleton
+pragma ComponentBehavior: Bound
+
+import QtQuick
+import Quickshell
+import Quickshell.Io
+import Quickshell.Wayland
+import Quickshell.Hyprland
+
+/**
+ * Provides access to some Hyprland data not available in Quickshell.Hyprland.
+ */
+Singleton {
+ id: root
+ property var windowList: []
+ property var addresses: []
+ property var windowByAddress: ({})
+ property var monitors: []
+
+ function updateWindowList() {
+ getClients.running = true
+ getMonitors.running = true
+ }
+
+ Component.onCompleted: {
+ updateWindowList()
+ }
+
+ Connections {
+ target: Hyprland
+
+ function onRawEvent(event) {
+ // Filter out redundant old v1 events for the same thing
+ if(event.name in [
+ "activewindow", "focusedmon", "monitoradded",
+ "createworkspace", "destroyworkspace", "moveworkspace",
+ "activespecial", "movewindow", "windowtitle"
+ ]) return ;
+ updateWindowList()
+ }
+ }
+
+ Process {
+ id: getClients
+ command: ["bash", "-c", "hyprctl clients -j | jq -c"]
+ stdout: SplitParser {
+ onRead: (data) => {
+ root.windowList = JSON.parse(data)
+ let tempWinByAddress = {}
+ for (var i = 0; i < root.windowList.length; ++i) {
+ var win = root.windowList[i]
+ tempWinByAddress[win.address] = win
+ }
+ root.windowByAddress = tempWinByAddress
+ root.addresses = root.windowList.map((win) => win.address)
+ }
+ }
+ }
+ Process {
+ id: getMonitors
+ command: ["bash", "-c", "hyprctl monitors -j | jq -c"]
+ stdout: SplitParser {
+ onRead: (data) => {
+ root.monitors = JSON.parse(data)
+ }
+ }
+ }
+}
+
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage