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?

Hello! Sorry for the aged response, thought I’d get email notification.

It works if I leave the tile there or close it, but if I move the tile back on normal workspace the special workspace remains in foreground and I can’t click normal workspace unless I move the tile back with same keybind or make another tile on active special workspace.

When you move the app off the special workspace, make sure whatever bind ur using has something like:

-- workspace = whatever ws you are moving to (eg 1,2,3,4,5 etc)
-- follow = true should focus the normal workspace. If the special one is empty,
-- it will essentially be destroyed when the last app leaves it,
-- until you again use something like the 'SUPER + S' bind you are using...
hl.dispatch(hl.dsp.window.move({ workspace = 1, follow = true }))

For some more advanced stuff with special workspaces, check out my reply in this thread

Ah, nice, I already have this as a separate mod key combo.