3

I am trying to open an application on a different desktop on my MacBook (macOS Sierra Version 10.12.5).

In the screenshot, I assigned Chrome to a different space (Desktop 1). I go to Desktop 2 and when I click on the Chrome icon, I am automatically switched to Desktop 1. How could I stay on Desktop 2?

Chrome is assigned to Desktop 1

EDIT

Maybe the logs are helpful. Which process does trigger the desktop switch? Console - All Messages

9
  • If you assigned Chrome to Desktop 1, when you click the Chrome icon you'll be taken to the desktop that you assigned for the application. If you don't want it assigned to Desktop 1, just select None. Is that what you're looking for?
    – fsb
    Commented Jul 17, 2017 at 23:47
  • @fsb No, I want to open the application silently, i.e. without being switched to a different desktop.
    – Andy
    Commented Jul 18, 2017 at 17:01
  • If you're on desktop 2 and then you click on the Chrome icon, it has to switch to desktop 1 because you assigned Chrome to desktop 1. I think you want it to open in desktop 1 while you still stay on desktop 2 on a different application. Is that correct?
    – fsb
    Commented Jul 18, 2017 at 17:19
  • @fsb yes, exactly! that is what I am looking for
    – Andy
    Commented Jul 18, 2017 at 17:24
  • 1
    This looked promising - cnet.com/uk/news/… - however it doesn't seem to work in El Capitan :/
    – Tetsujin
    Commented Jul 23, 2017 at 7:50

3 Answers 3

2
+50

From comments - as this appears to work for the OP, though I couldn't get it to work myself, on El Capitan.

From Keep applications from stealing focus when opening in OS X - by Topher Kessler [so at least it has a good pedigree, but it's from 2011]

To have a program always open in the background, you will need to edit a property list in the program package and add a couple of lines to the file. To do this, follow these instructions:

  1. Locate the application package file for the program in question.

  2. Right-click and choose "Show Package Contents."

  3. Navigate to the "Contents" directory within the application and open the "Info.plist" file in a text editor.

  4. Add the following lines to the file (the easiest location is to place them immediately after the <dict> tag, before the first <key> tag at the top of the document):

    <key>LSBackgroundOnly</key>
    <string>True</string>
    
  5. Save and close the file, and close the application package windows

After doing this, the program should now launch behind others at all times, and then only be brought to the front if you click a window for the program. As a word of warning, editing the contents of applications will break their code signature, which is required for some applications to automatically work with system services like the application firewall. Without an intact code signature, the system may always ask for you to allow applications through the firewall when they are launched, which may be a bit of an inconvenience. Additionally, this may not work for all applications, but it not then you can easily remove the added lines to restore full functionality to the program.

The second option for affecting a launching program is to develop a script that will launch it in the background. The basics for this script are to use the "open" terminal command, with the "-g" flag in the following manner (using iCal as an example):

open -g /Applications/iCal.app

As an alternative to providing the full path name to the application, you can use the "-a" flag as well and then only supply the application name, such as the following:

open -ga iCal

With these commands, you can set up a launcher for your programs either using AppleScript or Automator, where the script runs this command as a shell script to target the application of choice. For example, to create a script that will always launch iCal in the background, open Automator and create a new application workflow. Then add the "run shell script" action to the workflow and paste one of the above commands into the action's script field. Then save the workflow and when you run it, iCal should open behind your current application.

One caveat appears to be that the application can not be closed properly, i.e. its process is still present after closing it.

3

I have tried that in Yosemite but not in Sierra, but you could try to disable the desktop autoswitching.

Open terminal and enter:

defaults write com.apple.dock workspaces-auto-swoosh -bool NO

the restart the dock with

killall Dock

To revert to the default setting type

defaults write com.apple.dock workspaces-auto-swoosh -bool YES
killall Dock
4
  • thanks for the answer, but I already tried that.. it seems that this option is not taken into account at all. Could another setting overwrite this option?
    – Andy
    Commented Jul 18, 2017 at 18:36
  • Did you try to open an assigned app? And you weren't autoswitched on Yosemite?
    – Andy
    Commented Jul 18, 2017 at 18:37
  • @andy: Don't you think it would be helpful to mention what you already tried?
    – J.C.
    Commented Jul 18, 2017 at 18:39
  • probably yes, but I guess that much information would scare off some people
    – Andy
    Commented Jul 18, 2017 at 18:44
2

I get the performance you want by using the 'none' option when assigning an app to a desktop. But if the app is open on another desktop, you will be taken to that desktop if you try to open another instance of the app. I do not know a work around for this. Just be sure to not open app in a desktop other than the one you want. If there is a work around for this maybe another responder will know.

4
  • yes, once the app is opened in and assigned to a specific desktop, I can achieve this behaviour, e.g. by open -nF /Applications/Google\ Chrome.app/ in a Terminal on another desktop. But I don't want to have the app always running.
    – Andy
    Commented Jul 18, 2017 at 18:48
  • Sure, just be sure to only open it from the correct desktop. I don't have the option with Sierra to chose a desktop to assign it too.
    – Natsfan
    Commented Jul 18, 2017 at 18:53
  • Oh wait, I do have the option of choosing which desktop to assign it to. You can go to a certain desktop and then use assign to this desktop. Sorry
    – Natsfan
    Commented Jul 18, 2017 at 18:57
  • yes, but still the problem occurs if you click the app icon twice. Actually, I want to open and close an app on a different desktop space.. but this is a long way to go, yet
    – Andy
    Commented Jul 18, 2017 at 18:59

You must log in to answer this question.

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