0

Is there any way to have starting application not take the focus? Is there a setting so new windows do not pop over what we are currently working on? (Perhaps an option to have them pop under, or start minimized?)

Background: I use command line scripts (Terminal) to load my work environment each day, and can't use my computer while the script is running. (No biggy, I can just go do other things for a few minutes). VirtualBox is mainly the application where I notice this.

  • Thanks for the background. There are ways to make apps just launch but not activate (in applescript) but can you give a more detailed description of what you are doing, what the script is doing and what is actually happening to make you want this behaviour within the bounds of the workflow you will describe. – markhunte Mar 7 '14 at 7:33
2

open -jga TextEdit opens TextEdit hidden (-j) and without making it frontmost (-g). The -j option was added in 10.8 and it is only shown in the help message and not in the man page. If TextEdit is already running, open -ja TextEdit (without -g) would just make TextEdit frontmost and not hidden. For some applications like TextEdit and Mail, open -jg opens a new visible window if the application is running but has no open windows, but you can use something like pgrep -x TextEdit||open -jga TextEdit as a workaround.

A second option in 10.9 and later is lsappinfo launch launchandhide=true nofront=true /Applications/TextEdit.app.

A third option is osascript -e 'launch app "TextEdit"'. Unlike the open and lsappinfo commands, it is blocked until the application finishes opening. For some applications like TextEdit and Mail, the launch command opens a new visible window if the application is not already running.

Edit: none of the options above seem to work with VirtualBox, but you can hide VirtualBox after opening it:

open -jga VirtualBox;lsappinfo setinfo -app VirtualBox kLSApplicationIsHiddenKey=true

osascript -e 'launch app "VirtualBox"' -e 'delay 1' -e 'tell app "System Events" to set visible of process "VirtualBox" to false'

  • A lot of great tools! I was almost able to get it working with the lsappinfo utility (except that it wouldn't open a new item on the dock--could only open one virtual machine (perhaps there is an option to fix do that)). Ultimately, what worked for me was: open -gjn -a VirtualBox --args --startvm "virtual_machine_name" (where -n means start in new window, and everything after --args is included as command line arguments for the application that is specified with -a) :). Works wonderfully! – user2533809 Mar 8 '14 at 10:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .