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.

1 Like

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