gcamp
gcamp

Reputation: 14662

Launch app with NSWorkspace without activating it nor switch space

I try to launch an app in the background, without activating it. I just this method on NSWorkspace to launch it in the background :

[[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:bundleID
                               options:(NSWorkspaceLaunchWithoutActivation | 
                                        NSWorkspaceLaunchAllowingClassicStartup)
                               additionalEventParamDescriptor:nil launchIdentifier:NULL];

The only problem is that it doesn't activate the app but it does switch space to the assigned space of that application. Any way to avoid this?

Upvotes: 4

Views: 1245

Answers (1)

puzzle
puzzle

Reputation: 6131

Do you have any control over the app that you're launching? If so, override the window collection behavior of its windows. You'll probably want to make this controllable via a command line argument or similar methods, so the Spaces settings are still respected when the app is launched manually by the user.

If the app that you're launching is not under you control, how about using AppleScript to temporarily override its Space assignment, then change the assignment back to the original value?

Upvotes: 2

Related Questions