Design a site like this with WordPress.com
Get started

Nudge – Tips for Testing

If you’ve been around the Mac Admins community for a bit it is inevitable you’ll hear mention of Nudge. Nudge (written by Erik Gomez) fills an open hole in the macOS Software Update ecosystem by gently (or sometimes not so gently) guiding users to update their workstation in a timely manner. Nudge was also a big inspiration for me in creating my own first open source project: Renew.

This is not a beginners guide to Nudge. I’m writing this post because I came up with some basic tricks that helped me speed up my testing/iteration while I went through the learning curve of how the tool works.

I have some resources at the end of this post if you’re looking for guidance on how to implement Nudge.

Testing Cycle

While testing Nudge, I found myself repeating the same cycle over and over:

  • Change my profile or JSON
  • Trigger a Nudge event (mimic what the LaunchAgent does every 30 minutes)
  • Look at the logs to figure out what Nudge just did and why
  • Reset any deferrals and repeat

Any time I type the same thing 3 times, I start looking for easy-mode time saver tricks.

Make an Alias File

alias nudge='/Applications/Utilities/Nudge.app/Contents/MacOS/Nudge'
alias nudgereset="defaults delete ~/Library/Preferences/com.github.macadmins.Nudge.plist"
alias nudgelog="{ log stream --predicate 'subsystem '==' \"com.github.macadmins.Nudge\"' --info --style syslog --color none }"

Open Terminal, change to a directory of your liking, copy the code block above to your clipboard and then type:

pbpaste > nudge.aliases

This command will create a text file with the contents of your clipboard. I give mine the “.aliases” file extension, because it just doesn’t matter and this allows me to keep track of things. You can map this file extension to your favorite text editor application.

Once you’ve set this text file up, anytime you need to test your next Nudge configuration, you can navigate to that folder in Terminal and use:

source nudge.aliases

This gives you shortcuts in your current Terminal session that can greatly speed up your testing cycle. *Do not run these commands as sudo/root* Nudge is meant to be run in the user context (it works primarily off of a LaunchAgent, not a LaunchDaemon) and the deferral file is kept within the current user’s Library folder.

nudge #Use this to trigger a Nudge event. This is what happens when the Launch Agent runs on :00 and :30 by default

nudgereset #Use this to reset the deferral plist and cancel any current deferral

The Nudge Logger, on the other hand, does run as a LaunchDaemon and requires sudo to review the logs. So my practice was to have a second Terminal window open and logged into an administrator account. Then change directories to where my nudge.aliases file lives, and use:

sudo -s #Enter your administrator password
source nudge.aliases

Then I ran this command to stream the logs in real time:

nudgelog

Resources

If you’d like to learn more about Nudge and how it works or how to customize it, these are some of the resources I took in when I was learning:

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s