From fba67168d9e2c44c07ba6660d2bdc939b20a57f5 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Fri, 16 May 2025 19:12:09 +0200 Subject: [PATCH] cheatsheet: support user keybinds --- .config/hypr/custom/keybinds.conf | 10 ++++- .../quickshell/services/HyprlandKeybinds.qml | 37 +++++++++++++++++-- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/.config/hypr/custom/keybinds.conf b/.config/hypr/custom/keybinds.conf index f34545cef..d3079441d 100644 --- a/.config/hypr/custom/keybinds.conf +++ b/.config/hypr/custom/keybinds.conf @@ -1,2 +1,8 @@ -# You can put your preferred keybinds here -# https://wiki.hyprland.org/Configuring/Binds/ \ No newline at end of file +# See https://wiki.hyprland.org/Configuring/Binds/ +#! +##! User keybinds +bind = Ctrl+Super+Alt, Slash, exec, xdg-open ~/.config/hypr/custom/keybinds.conf # Edit custom keybinds + +# Add stuff here +# Use #! to add an extra column on the cheatsheet +# Use ##! to add a section in that column diff --git a/.config/quickshell/services/HyprlandKeybinds.qml b/.config/quickshell/services/HyprlandKeybinds.qml index 54299ede8..72d2dce32 100644 --- a/.config/quickshell/services/HyprlandKeybinds.qml +++ b/.config/quickshell/services/HyprlandKeybinds.qml @@ -11,7 +11,18 @@ import Quickshell.Hyprland Singleton { id: root - property var keybinds: [] + property var defaultKeybinds: [] + property var userKeybinds: [] + property var keybinds: ({ + children: [ + ...defaultKeybinds.children, + ...userKeybinds.children, + ] + }) + + // onKeybindsChanged: { + // console.log("[CheatsheetKeybinds] Keybinds changed:", JSON.stringify(keybinds, null, 2)) + // } Connections { target: Hyprland @@ -19,13 +30,14 @@ Singleton { function onRawEvent(event) { console.log("[CheatsheetKeybinds] Event:", event.name) if (event.name == "configreloaded") { - getKeybinds.running = true + getDefaultKeybinds.running = true + getUserKeybinds.running = true } } } Process { - id: getKeybinds + id: getDefaultKeybinds running: true command: [FileUtils.trimFileProtocol(`${XdgDirectories.config}/quickshell/scripts/hyprland/get_keybinds.py`), "--path", FileUtils.trimFileProtocol(`${XdgDirectories.config}/hypr/hyprland/keybinds.conf`),] @@ -33,7 +45,24 @@ Singleton { stdout: SplitParser { onRead: data => { try { - root.keybinds = JSON.parse(data) + root.defaultKeybinds = JSON.parse(data) + } catch (e) { + console.error("[CheatsheetKeybinds] Error parsing keybinds:", e) + } + } + } + } + + Process { + id: getUserKeybinds + running: true + command: [FileUtils.trimFileProtocol(`${XdgDirectories.config}/quickshell/scripts/hyprland/get_keybinds.py`), + "--path", FileUtils.trimFileProtocol(`${XdgDirectories.config}/hypr/custom/keybinds.conf`),] + + stdout: SplitParser { + onRead: data => { + try { + root.userKeybinds = JSON.parse(data) } catch (e) { console.error("[CheatsheetKeybinds] Error parsing keybinds:", e) }