From b707a6ee3ebfb5b527af63f0eacfb63ec1a580cb Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Tue, 8 Jul 2025 18:25:20 +0800 Subject: init --- services/Hyprland.qml | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 services/Hyprland.qml (limited to 'services') diff --git a/services/Hyprland.qml b/services/Hyprland.qml new file mode 100644 index 0000000..84db674 --- /dev/null +++ b/services/Hyprland.qml @@ -0,0 +1,51 @@ +pragma Singleton + +import Quickshell +import Quickshell.Hyprland +import QtQuick +import "../config" + +Singleton { + id: root + + readonly property var toplevels: Hyprland.toplevels + readonly property var workspaces: Hyprland.workspaces + readonly property var monitors: Hyprland.monitors + // readonly property HyprlandToplevel activeToplevel: Hyprland.activeToplevel + readonly property HyprlandWorkspace focusedWorkspace: Hyprland.focusedWorkspace + readonly property HyprlandMonitor focusedMonitor: Hyprland.focusedMonitor + readonly property int activeWs: focusedWorkspace?.id ?? 1 + + function dispatch(request: string): void { + Hyprland.dispatch(request); + } + + function getAllWorkspaces(): var { + var allWorkspaces = { + values: [], + count: 0 + }; + for (let i = 1; i <= Bar.workspaces; i++) { + if (workspaces[i] === undefined) { + allWorkspaces.values[i] = HyprlandWorkspace; + } + } + return allWorkspaces; + } + + Connections { + target: Hyprland + + function onRawEvent(event: HyprlandEvent): void { + if (event.name.endsWith("v2")) + return; + + if (event.name.includes("mon")) + Hyprland.refreshMonitors(); + else if (event.name.includes("workspace")) + Hyprland.refreshWorkspaces(); + // else + // Hyprland.refreshToplevels(); + } + } +} -- cgit v1.2.3