Nudge releases generally come as Nudge, Nudge logger, and the Nudge launch agent. As of this writing, the Nudge launch agent will launch up Nudge every 30 minutes. The package is also signed:
If you’re creating your own launch agent, you may want to code-sign it, or you may not have to, depending on how you’re deploying the launch agent.
Here’s an example of how you can change the launch agent, in case you don’t want it to run as aggressively (or maybe you want it to run more aggressively!).
I’m writing this as a series of terminal commands, so it’s easy to reproduce, but you can certainly use a point-and-click tool for creating custom packages to do the same thing.
The bottom line is that you want to deliver the (modified) launch agent to the
/Library/LaunchAgents directory, and then you want to run a postinstall script to load up the launch agent as the currently logged-in user.
Find a folder you want to use as your workspace. It could be something like
~/Desktop. For this example, I’m just going to use the desktop.
Make a clone of the munkipkg GitHub repo:
git clone email@example.com:munki/munki-pkg.git
Make a clone of the Nudge GitHub repo:
git clone firstname.lastname@example.org:macadmins/nudge.git
Since macOS 12.3, Apple removed
/usr/bin/python, so you’ll have to install Python and use the Python you installed. For this example, I’m going to use Munki‘s Python.
Create a new empty munkipkg project:
/usr/local/munki/munki-python munki-pkg/munkipkg --create nudge_launch_agent
Create the necessary subdirectories within the new project you just created:
mkdir -p nudge_launch_agent/payload/Library/LaunchAgents
mkdir -p nudge_launch_agent/scripts
Copy the launch agent from the Nudge project clone to your new launch agent package project:
cp nudge/build_assets/com.github.macadmins.Nudge.plist nudge_launch_agent/payload/Library/LaunchAgents/
Copy the postinstall script from the Nudge project clone to your new launch agent package project:
cp nudge/build_assets/postinstall-launchagent nudge_launch_agent/scripts/postinstall
Open the launch agent .plist and edit it so that it’s not run every half hour:
If you don’t know how
StartCalendarInterval works for launch agents, you may want to read Apple’s official documentation on launchd or MacOS launchd plist StartInterval and StartCalendarInterval examples.
Here are a couple of examples, though.
If you want Nudge to run twice a day, you can have the
StartCalendarInterval look something like this:
If you want Nudge to run once an hour, you do something like this instead:
Once you’re done editing, go ahead and build your new package:
/usr/local/munki/munki-python munki-pkg/munkipkg nudge_launch_agent
You should now see a newly built package with your own custom launch agent for Nudge:
Now that you have this project created, you can skip all the earlier steps in the future. Any time you want to modify the launch agent again, just go back to this project, edit the launch agent, open the
build-info.plist to increment the package version, and then use
munkipkg to recreate a new launch agent package.