fixed hyprland issue
This commit is contained in:
1 parent
d42e24be81
commit
b127fc2256
2 files changed
+18
-3
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user