blob: 189ba76d51d33e8935012466a220f09e0dd5a79d (
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
70
71
72
73
|
pragma Singleton
pragma ComponentBehavior: Bound
import "root:/modules/common"
import "root:/modules/common/functions/file_utils.js" as FileUtils
import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Wayland
import Quickshell.Hyprland
/**
* A service that provides access to Hyprland keybinds.
* Uses the `get_keybinds.py` script to parse comments in config files in a certain format and convert to JSON.
*/
Singleton {
id: root
property string keybindParserPath: FileUtils.trimFileProtocol(`${Directories.config}/quickshell/scripts/hyprland/get_keybinds.py`)
property string defaultKeybindConfigPath: FileUtils.trimFileProtocol(`${Directories.config}/hypr/hyprland/keybinds.conf`)
property string userKeybindConfigPath: FileUtils.trimFileProtocol(`${Directories.config}/hypr/custom/keybinds.conf`)
property var defaultKeybinds: {"children": []}
property var userKeybinds: {"children": []}
property var keybinds: ({
children: [
...(defaultKeybinds.children ?? []),
...(userKeybinds.children ?? []),
]
})
Connections {
target: Hyprland
function onRawEvent(event) {
if (event.name == "configreloaded") {
getDefaultKeybinds.running = true
getUserKeybinds.running = true
}
}
}
Process {
id: getDefaultKeybinds
running: true
command: [root.keybindParserPath, "--path", root.defaultKeybindConfigPath,]
stdout: SplitParser {
onRead: data => {
try {
root.defaultKeybinds = JSON.parse(data)
} catch (e) {
console.error("[CheatsheetKeybinds] Error parsing keybinds:", e)
}
}
}
}
Process {
id: getUserKeybinds
running: true
command: [root.keybindParserPath, "--path", root.userKeybindConfigPath]
stdout: SplitParser {
onRead: data => {
try {
root.userKeybinds = JSON.parse(data)
} catch (e) {
console.error("[CheatsheetKeybinds] Error parsing keybinds:", e)
}
}
}
}
}
|