diff options
| author | Ja.KooLit <85185940+JaKooLit@users.noreply.github.com> | 2025-06-15 17:08:35 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-15 17:08:35 +0000 |
| commit | 88abbee9fe56f2e2489f04a017daaf3cfdc97511 (patch) | |
| tree | c229832f852a3e55b41addcfc675d3ceb3df2282 /config/quickshell/services/HyprlandKeybinds.qml | |
| parent | 4cf0d0bd5930da76e60f6770de3ee97c10ca7024 (diff) | |
| parent | d46077fe5ac56afbd63dc1222e649f10435b05e2 (diff) | |
Merge pull request #737 from SherLock707/overviewV2_qs
Overview Widget v2: Migration from AGS to QuickShell
Diffstat (limited to 'config/quickshell/services/HyprlandKeybinds.qml')
| -rw-r--r-- | config/quickshell/services/HyprlandKeybinds.qml | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/config/quickshell/services/HyprlandKeybinds.qml b/config/quickshell/services/HyprlandKeybinds.qml new file mode 100644 index 00000000..189ba76d --- /dev/null +++ b/config/quickshell/services/HyprlandKeybinds.qml @@ -0,0 +1,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) + } + } + } + } +} + |
