Special workspace overlay

Hyprland version

Hyprland 0.56.2

On my original hyprlang config I used this syntax:

windowrule = workspace special:spotify, match:class ^(spotify|Spotify)$

and

bind = $mainMod, S, exec, sh -c 'if ! pgrep -x spotify-launcher >/dev/null; then spotify-launcher & fi; hyprctl dispatch togglespecialworkspace spotify'

making a special workspace the overlayed spotify on my currently open workspace without closing it, but on the new lua config when trying to replicate this:

hl.bind(
    mainMod .. " + S",
    hl.dsp.exec_cmd(
        "pgrep -x spotify-launcher >/dev/null || spotify-launcher; hyprctl dispatch togglespecialworkspace spotify"
    )
)
hl.window_rule({
    name = "spotify-special-workspace",
    match = {
        class = "^(spotify|Spotify)$"
    },
    workspace = "special:spotify"
})

it opens the special workspace and closes the currently open window.

does anyone know what I did wrong or how to fix it?

that doesn’t work in lua. With lua, dispatch is a shorthand for eval hl.dispatch(...). :)

Thank you vaxry :+1:, I also realized that mainMod + C was a fallback/default kill window command so changing the bind fixed the window closing problem.