SMLoginItemSetEnabled helper tool questions

We have a simple sandboxed app with important checkbox, and toggling it enables a system-wide setting. In order for this setting to be applied at login, we use a Service Management login item installed via SMLoginItemSetEnabled, located in in the main app bundle’s Contents/Library/LoginItems folder.

A couple of questions:

  1. General — does the helper tool need to launch the main app, or can it apply the setting itself? All we have to do is apply a setting at login without showing UI, then terminate the app.

  2. Technical — does the helper tool need to be a full application bundle, or can it be just a simple sandboxed command line tool, since it has no UI?

Any suggestions are welcome on how to elegantly solve this and still fly in Mac App Store.

Accepted Reply

I just emailed you the details.

Thanks.

It sounds like your primary concern is the ‘weight’ of a Service Management login item. That is, you think that such a login item would be more expensive than, say, running a shell script via a launchd agent. That’s not the case. Running a process is relatively expensive, and the difference in cost between two different processes largely depends on what those processes do. Indeed, if you strip down your Service Management login item to just the code that calls the API to set the state you need, it will be less expensive than a launchd agent that runs a shell script that runs a built-in tool because:

  • The latter approach needs two processes.

  • The built-in tool is a general-purpose thing, which means it’ll be more expensive than your special-purpose code.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Replies

My understanding is that you have sandboxed app with a Service Management login item. Which brings me to this:

does the helper tool need to launch the main app, or can it apply the setting itself?

What is “helper tool” in this context?

Also, with regards this:

important checkbox

Is that a typo? ‘cause I figured that all the checkboxes in your app were important (-:

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Since the state of the above mentioned setting isn’t persistent between macOS restarts, we need to apply it every time at login (as long as user has enabled this preference).

Can we have a background daemon that starts at login in order to apply a setting (daemon is immediately terminated afterword)? Or is it necessary for Mac App Store distribution to have the full main app always launch?

Is that a typo? ‘cause I figured that all the checkboxes in your app were important (-:

I think I choose words intentionally ;-)

Since the state of the above mentioned setting isn’t persistent between macOS restarts

OK, I’m clearly missing something hehre. What setting are you talking about here? And why doesn’t it persist?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • I just emailed you the details. I think you’ll find it interesting. let myEmail = "rakic" + "@" + "me.com"

Add a Comment

I just emailed you the details.

Thanks.

It sounds like your primary concern is the ‘weight’ of a Service Management login item. That is, you think that such a login item would be more expensive than, say, running a shell script via a launchd agent. That’s not the case. Running a process is relatively expensive, and the difference in cost between two different processes largely depends on what those processes do. Indeed, if you strip down your Service Management login item to just the code that calls the API to set the state you need, it will be less expensive than a launchd agent that runs a shell script that runs a built-in tool because:

  • The latter approach needs two processes.

  • The built-in tool is a general-purpose thing, which means it’ll be more expensive than your special-purpose code.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"