Launching and configuring terminal window from oF application

Hi guys i was just searching for a way to launch a terminal window, set its size and position on the screen and then be able to open a text file in vim for editing. Basically something like this -> but be able to launch it from within an openFrameworks application.

Would anybody be able to point me in a direction to look into. Thanks.

Hi there!

Yesterday, Zach posted a tip to a similar issue, so I will just quote him:

In your case, you can do system(“osascript -e ‘tell application “Terminal” to activate’”); to launch terminal.

Also, see my SO answer to the same question:

1 Like

Thanks @bakercp and @hubris I have just played around and got a basic version of what i need using the below commands

    system("osascript -e 'tell application \"Terminal\" to activate'"); // Open Terminal
    system("osascript -e 'tell application \"Terminal\" to get bounds of window 1'"); // Get bounds of Terminal on screen
    system("osascript -e 'tell application \"Terminal\" to do script \"say hello\"'"); // Send Command to terminal window

    system("osascript -e 'tell application \"Terminal\" to set bounds of window 1 to {10, 80, 600,400}'"); // Set new bounds of Terminal Window

As I was doing this my mate sent my this project that was created in oF and uses URXVT and BSPWM to create a boardless terminal window on top of the oF application hence making it feel integrated with the UI of the app. Pretty much exactly what i’ve been looking to do.

Going to have a bigger dig around now and see how far i can get. Thanks guys!

1 Like

i am on OS X 10.10 with OF 0.8.4

this works:

system("osascript -e 'tell application \"Terminal\" to quit'");

but when i try that on a OF compiled app the app does not quit.

for example:

 system("osascript -e 'tell application \"opencvHaarFinderExampleDebug\" to quit'")

any ideas why?

using automator to quit the OF app works but as i said with Apple Script it doesn’t

The name of your application may not match the process. Can you check it on the Activity Monitor?

I checked and they do match.
I have read online of other non-OF apps that don’t react either.

Some more tests shows:
When compiling an app via Xcode, then starting it by double clicking app icon, apple script can quit the app.
BUT when moving the app for example tot he desktop then start it, apple script can’t quit it.
Then trying run the app in it’s original location, now apple script can’t quit it.

this works though.

tell application "/Users/stephan/Desktop/bin/" to quit

Hum… Strange. I’m able to quit applications with no problems…
Could this be an issue with admin/folder permissions?

But if the full path works for you, maybe this can be helpful:

thanks for the link. i tried it just now. but doesn’t help :frowning:

the thing is, the “quit” call doesn’t even work from within apple script editor.

fyi i am on OS X 10.10 with OF 0.8.4

I’m on the same OS.

Have you tried through the command line? Maybe something like:

system("osascript -e 'tell application \"Terminal\" to do script \"killall [yourApp]\"'");
system("osascript -e 'tell application \"Terminal\" to do script \"killall opencvHaarFinderExampleDebug\"'");

YES. this works. great.
I was worried that killall would force quit the app and not exit it correctly… But I was wrong, even the exit() part of my opencvHaarFinderExampleDebug app got called correctly.