This question already has an answer here:

Trying to get rid of Spotify's startup at login time I found an interesting behavior: while its plists are not present in any of the known locations such as Library/LaunchAgents and Library/LaunchDaemons and it's also not set to Open at Login either in the Dock or during logout, it still manages to start up somehow.

I've created a new test user, started the app just once, was greeted with a login prompt, closed the app and it decided it would start ever since. I've tried deleting the entire contents of the user's home folder in the Terminal while running as another user (rm -rf /users/testuser/*), but Spotify would start anyway.

Wonder how they do that? It's pretty easy to check by downloading and running the app, there's no need to even create an account.

The point of the question is to understand the mechanism rather than actually stop it from opening (there's a switch in the app).

marked as duplicate by Allan, Monomeeth Dec 1 '18 at 3:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • One idea that crossed my mind just now is to run fs_usage|grep otify while using that switch, but I am not able to log in right now and cannot access that switch. – Захар Joe Nov 23 '18 at 7:34
  • can you tell us what Mac and what OSX – Ruskes Nov 23 '18 at 7:59
  • OSX 10.11.6, Mac Pro early 2008 – Захар Joe Nov 23 '18 at 12:22

A lot of functionality, like login items, extensions/kexts, LaunchAgents or other Helpers can be packed into the application bundle these days.

If you look closely at the content of the Spotify.app, by right- or control clicking it and selecting "Show Package Contents", you'll find a "Library" folder enclosed in the Content's folder. Within it there is a LoginItems folder, containing the login item. /Applications/Spotify.app/Contents/Library/LoginItems/StartUpHelper.app/Contents/MacOS/StartUpHelper

This "StartUpHelper" will launch Spotify at login. This seems to be the application's default behaviour.

You wrote:

Otherwise it would start for every new user added to the system.

I certainly have seen Spotify auto-launch on a user created after it had been installed, logging out of the user that created the new account and setting up the new user account from the login screen (alternatively two restarts were needed for Spotify to launch at login in the new user account).
Only when Spotify got installed after the user was created, did it not launch at login.

A test in an attempt to explain, why some users will not see the auto-launch of Spotify at login:

I created and set up a new user before Spotify was installed on a different user account and, after Spotify was installed (again in a different user account), tried several logouts/logins and restarts to make sure it didn’t auto-launch at login for this new user.
I also noted the user’s DARWIN USER DIRECTORY running the following command...

I also had a user for whom Spotify auto-launched at login every single time. Again I noted the user’s DARWIN USER DIRECTORY.
Logged into this last mentioned user I quit Spotify and deleted...
...from the Darwin User Directory.
Then I copied the same file from the other user’s Darwin User Directory (for whom Spotify didn’t auto-launch at login) over to this user’s directory (in Finder, to make sure the file’s owner would also change).

Then I logged out and rebooted several times into the user, for whom Spotify did auto-launch, but the behaviour stopped and Spotify refrained from launching.

PS. For further in depth information on login items within an application bundle, I’d suggest signing up for a free Developer account and getting acquainted with (some of) the documentation on application design (you don't have to sign up though, just to read the documentation).

  • Sure, but however tightly you pack the bundle doesn't explain how the app should start up by itself. There has to be something starting it. – Захар Joe Nov 23 '18 at 12:27
  • @ЗахарJoe I do not know what you mean by "however tightly you pack the bundle". The preference you set in the app either starts it or doesn't. The StartUpHelper then launches it. Did you read the document I linked to at the Developer site? – Redarm Nov 23 '18 at 12:36
  • Yes, I did read it. A part of it references opening applications as a part of doing some work, like when opening a document, and then there's a reference to Info.plist which supposedly controls a startup of a helper app - there're no strings they reference in Spotify helper app's Info.plist. Furthermore, I see nowhere how a plist placed systemwide on a helper app would "know" whether it should start for a particular user, and that's precisely what happens. Otherwise it would start for every new user added to the system. – Захар Joe Nov 23 '18 at 12:48
  • I'm guessing the app has to register itself with Launch Services first (i.e. launch at least once) and maybe get rid of the quarantine attribute, before it can exhibit its default behaviour of launching at login. – Redarm Nov 23 '18 at 14:40
  • 1
    As an aside: since deleting the file mentioned in my comment above, gets rebuilt for the next startup, a more permanent and the proper way is to de-register Spotify from Launch Services: /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -u /Applications/Spotify.app (which doesn't show you the file(s) in the file system though) – Redarm Nov 24 '18 at 14:59

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