Question about Applescript to check if workspace is open

I am currently mapping tell application id "DNtp" to load workspace "Home" to a modifier key to open a workspace.

My problem is that when I use the function, a set of all corresponding workspace windows are created.

Is there any way to check if a workspace is active? If it is active, is there a way to focus on those windows, as opposed to creating a new set of windows?

current workspace? Typing “workspace” in the script editor’s function library view tells you all about the available properties and commands. I suppose that only one workspace can be open at all times, so

tell application id "DNtp"
  if (current workspace is not "Home") 
     load workspace "Home"
  end if
end tell

or something like that might do the trick. (I’m not sure about AppleScript’s if syntax, though!)

1 Like

Welcome @luis_al92

Go to Script menu > More Scripts and install **Open Clean Workspace.

1 Like