1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 05:25:41 -05:00
Files
DankMaterialShell/quickshell/Services/KeybindsService.qml
2025-11-12 17:18:45 -05:00

61 lines
1.3 KiB
QML

pragma Singleton
pragma ComponentBehavior: Bound
import QtQuick
import QtCore
import Quickshell
import Quickshell.Io
import qs.Common
Singleton {
id: root
property string currentProvider: "hyprland"
property var keybinds: ({"title": "", "provider": "", "binds": []})
Process {
id: getKeybinds
running: false
command: ["dms", "keybinds", "show", root.currentProvider]
stdout: StdioCollector {
onStreamFinished: {
try {
root.keybinds = JSON.parse(text)
} catch (e) {
console.error("[KeybindsService] Error parsing keybinds:", e)
}
}
}
onExited: (code) => {
if (code !== 0 && code !== 15) {
console.warn("[KeybindsService] Process exited with code:", code)
}
}
}
Timer {
interval: 500
running: true
repeat: false
onTriggered: {
getKeybinds.running = true
}
}
function loadProvider(provider) {
root.currentProvider = provider
reload()
}
function reload() {
if (getKeybinds.running) {
getKeybinds.running = false
}
Qt.callLater(function() {
getKeybinds.running = true
})
}
}