Help to figure out the special workspace check conditional for a bind function

Hyprland version
Hyprland 0.55.4 built from branch v0.55.4 at commit a0136d8c04687bb36eb8a28eb9d1ff92aea99704 clean ([gha] Nix: update inputs).
Date: Thu Jun 11 17:10:04 2026
Tag: v0.55.4, commits: 7378

Libraries:
Hyprgraphics: built against 0.5.1, system has 0.5.1
Hyprutils: built against 0.13.1, system has 0.13.1
Hyprcursor: built against 0.1.13, system has 0.1.13
Hyprlang: built against 0.6.8, system has 0.6.8
Aquamarine: built against 0.12.0, system has 0.12.1

Version ABI string: a0136d8c04687bb36eb8a28eb9d1ff92aea99704_aq_0.12_hu_0.13_hg_0.5_hc_0.1_hlg_0.6
no flags were set

I’m trying to make a small function and need help getting the conditional right, which should be to check if the special workspace exists and if it has no windows on it.

hl.bind(“SUPER + S”, function()
local sw = hl.get_workspace(“special:magic”)
if not sw or sw.get_windows == nil then
hl.dsp.window.move({ workspace = “special:magic”, follow = false })
else
hl.dsp.workspace.toggle_special(“magic”)
end
end)

Sure mate, here you go:

hl.bind('SUPER + S', function()
  -- will return a table of windows on the workspace, or
  -- an empty table if no workspace or no windows on the workspace
  local ws_windows = hl.get_workspace_windows('special:magic') 
  if #ws_windows == 0 then
    hl.dispatch(hl.dsp.window.move({ workspace = 'special:magic', follow = false }))
  else
    hl.dispatch(hl.dsp.workspace.toggle_special('magic'))
  end
end)

@Yngviwarr did that snippet work for you?