blob: 2b88ad9cc5138b16246e2923a2a539d59d01847c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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)
}
}
}
}
|