cheatsheet: support user keybinds

This commit is contained in:
end-4
2025-05-16 19:12:09 +02:00
parent 3cc45e37fc
commit fba67168d9
2 changed files with 41 additions and 6 deletions
+8 -2
View File
@@ -1,2 +1,8 @@
# You can put your preferred keybinds here # See https://wiki.hyprland.org/Configuring/Binds/
# 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
@@ -11,7 +11,18 @@ import Quickshell.Hyprland
Singleton { Singleton {
id: root 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 { Connections {
target: Hyprland target: Hyprland
@@ -19,13 +30,14 @@ Singleton {
function onRawEvent(event) { function onRawEvent(event) {
console.log("[CheatsheetKeybinds] Event:", event.name) console.log("[CheatsheetKeybinds] Event:", event.name)
if (event.name == "configreloaded") { if (event.name == "configreloaded") {
getKeybinds.running = true getDefaultKeybinds.running = true
getUserKeybinds.running = true
} }
} }
} }
Process { Process {
id: getKeybinds id: getDefaultKeybinds
running: true running: true
command: [FileUtils.trimFileProtocol(`${XdgDirectories.config}/quickshell/scripts/hyprland/get_keybinds.py`), command: [FileUtils.trimFileProtocol(`${XdgDirectories.config}/quickshell/scripts/hyprland/get_keybinds.py`),
"--path", FileUtils.trimFileProtocol(`${XdgDirectories.config}/hypr/hyprland/keybinds.conf`),] "--path", FileUtils.trimFileProtocol(`${XdgDirectories.config}/hypr/hyprland/keybinds.conf`),]
@@ -33,7 +45,24 @@ Singleton {
stdout: SplitParser { stdout: SplitParser {
onRead: data => { onRead: data => {
try { 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) { } catch (e) {
console.error("[CheatsheetKeybinds] Error parsing keybinds:", e) console.error("[CheatsheetKeybinds] Error parsing keybinds:", e)
} }