Refocusing terminal after closing GUI window

I’m using a button on a MIDI controller through MIDIdef to close a GUI window. However when closing the window to terminal does not automatically refocus and you have to do this manually with a mouse. It’s for a piece for an exhibition so I want the only interaction to be through the MIDI controllers. Is there anyway to do this through Supercollider?

I’ve tried setting


any suggestions?

I don’t quite understand what you mean by refocusing the terminal. Why do you need focus on a specific window if you’re interacting using MIDI controllers and what window needs to have focus?

When you say ‘terminal’, do you mean the terminal in the OS, or do you mean SCide?

If you post some more info about what computer and what OS etc. you are using it easier to help you. And if you can include a code example that would be even more helpful.


Sorry if I’m not being clear! So the first part of the interaction takes place by running some Python code in the OS terminal, which is then sending OSC to Supercollider. On receiving the message it will bring up a GUI window from Supercollider. Once the user has finished making sound through the GUI they will press a button on the MIDI controller to close the window. However when this happens, the OS terminal is then out of focus and needs to be clicked on by a mouse.


				OSCdef( \test4, {
					arg msg; 

if (msg != 0,
								w ="test",, yPos, wWidth, wHeight))
								.front // bring to front
								.alwaysOnTop_(true) // different syntax for w.alwaysOnTop = true;
								.background_(Color(78/255, 80/255, 85/255))


Thanks in advance!

I dont’ what OS you running so I can only assume you are using macOS:
On macOS you could do:

var terminalApp = "iTerm2"; //or "Terminal" if that's your choice
"osascript -e 'tell application \"%\" to activate'".format(terminalApp).unixCmd;