summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-07-08 18:25:20 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-07-08 18:25:20 +0800
commitb707a6ee3ebfb5b527af63f0eacfb63ec1a580cb (patch)
tree47008e296e936b32287c5cf9ebe065a119f5b2aa /services
init
Diffstat (limited to 'services')
-rw-r--r--services/Hyprland.qml51
1 files changed, 51 insertions, 0 deletions
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();
+ }
+ }
+}