Detect current active space number?

Hi, here's what I'm trying to accomplish:

  • A single hotkey to open a new Chrome tab with the correct profile
  • If I'm viewing Space #1, use my personal profile
  • Otherwise, use my work profile

Is there a way for BTT to detect which Space is currently active? Or does anyone have another suggestion for how to accomplish this?

Thanks!

In the latest alpha (4.725) I added a on-demand variable "ActiveSpace" for this, you can e.g. use it in an if condition.

async function someJavaScriptFunction() {

	let activeSpace = get_number_variable("ActiveSpace");
	
	if(activeSpace == 4) {
	    return true
	}
	
	return false;
}

Note: the space id is not equivalent to what the space is called in the macOS UI.

Hi Andreas — that's great, thank you! I'll try it.

Worked perfectly! Thank you.

Here's what I'm doing. Looks like my first space has the ID of 3. Happily, this persists across restarts.

async function isPersonalSpace() {

return await get_number_variable("ActiveSpace") == 3;

}

Is there a way to get the number of the desktop (space) into a floating menu (the text of the menu)?
I didnt find the way to do it so far.
tried this

thank you

In 5.599 alpha I made the active_space and translated_active_space variables observable. This means you can now do this without any scripting (just put it in curly braces - e.g. {translated_active_space}):

I also added a new "Active Space Did Change" trigger.

thank you very much, this solves my biggest issue with macos and that is knowing what space im in ( according to various forums, many other users struggle with this too).:folded_hands: