Skip to main content
Solved

Start a launch agent as user?

  • June 26, 2024
  • 1 reply
  • 216 views

howie_isaacks
Forum|alt.badge.img+23

I'm working on a new post install script for Nudge. Delivering Nudge settings using a profile has not been as reliable as I would like it to be. I found Dan Snelson's Nudge post install script (https://github.com/dan-snelson/Nudge-Post-install/wiki) and it has been a good starting point. Its command to load the launch agent doesn't work. My understanding is that we need to use Launchctl bootstrap instead of Launchctl load as we did with older versions of macOS. I have other scripts that load launch daemons that use bootstrap/bootout. These work well. Since a launch agent loads when a user logs in, it's different. What is the proper command to load a launch agent using a script deployed by Jamf Pro? If I can get this one thing to work, it pretty much wraps up getting this done. 

Best answer by RaGL

For LaunchAgents, I'm always using the following pattern:

#!/bin/bash Name_loggedInUser=$(stat -f %Su /dev/console) UID_loggedInUser=$(id -u $Name_loggedInUser) launchctl bootstrap gui/$UID_loggedInUser <path to LaunchAgent plist>

 

1 reply

RaGL
Forum|alt.badge.img+7
  • Contributor
  • Answer
  • June 27, 2024

For LaunchAgents, I'm always using the following pattern:

#!/bin/bash Name_loggedInUser=$(stat -f %Su /dev/console) UID_loggedInUser=$(id -u $Name_loggedInUser) launchctl bootstrap gui/$UID_loggedInUser <path to LaunchAgent plist>