diff --git a/workspace-badge/Compositor.qml b/workspace-badge/Compositor.qml index 3f793b3..9dd7e49 100644 --- a/workspace-badge/Compositor.qml +++ b/workspace-badge/Compositor.qml @@ -151,10 +151,16 @@ Item { return; const idText = String(id); // Hyprland has no "clear name", so fall back to the numeric id. - root.runAll([["hyprctl", "dispatch", "renameworkspace", idText, name.length > 0 ? name : idText]]); + const label = name.length > 0 ? name : idText; + root.runAll([["hyprctl", "dispatch", "hl.dsp.workspace.rename({ workspace = " + idText + ", name = " + root.luaString(label) + " })"]]); } } + // Quote a string for a Lua expression (Hyprland 0.55+ takes Lua). + function luaString(text: string): string { + return "\"" + text.replace(/[\r\n]+/g, " ").replace(/[\\"]/g, "\\$&") + "\""; + } + function runAll(commands): void { root.actionQueue = root.actionQueue.concat(commands); if (!action.running) @@ -213,6 +219,15 @@ Item { onExited: root.runNext() + // hyprctl prints its errors on stdout and says "ok" on success. + stdout: StdioCollector { + onStreamFinished: { + const text = this.text.trim(); + if (text.length > 0 && text !== "ok") + console.warn("workspace-badge:", text); + } + } + stderr: StdioCollector { onStreamFinished: { if (this.text.trim().length > 0) diff --git a/workspace-manager/Compositor.qml b/workspace-manager/Compositor.qml index 09879d5..23041b5 100644 --- a/workspace-manager/Compositor.qml +++ b/workspace-manager/Compositor.qml @@ -424,7 +424,7 @@ Item { if (root.kind === "niri") action.command = ["niri", "msg", "action", "focus-window", "--id", key]; else if (root.kind === "hyprland") - action.command = ["hyprctl", "dispatch", "focuswindow", "address:" + key]; + action.command = ["hyprctl", "dispatch", "hl.dsp.focus({ window = \"address:" + key + "\" })"]; else return; action.running = false; @@ -464,7 +464,7 @@ Item { } else if (root.kind === "hyprland") { if (id < 0) return; - root.focusQueue = [["hyprctl", "dispatch", "workspace", String(id)]]; + root.focusQueue = [["hyprctl", "dispatch", "hl.dsp.focus({ workspace = \"" + String(id) + "\" })"]]; } else { return; }