Automating Script Execution

But why run and update Xplanet manually, when you can automate.

Property Lists to Launch on Boot and Update (plist)

One of the major changes Apple has made in OS X, and is starting to enforce more stringently, is the use of launchd instead of cron.  Both these utilities act as a time-based job schedulers to run commands or shell scripts.  While cron is an order of magnitude easier to define and use, it does have limitations that launchd resolves.  While you can probably still use cron on OS X 10.8, Apple has officially deprecated its functionality.

I’m making my plist archive available as part of the broader archive available in the Summary.  Go to ~/.xplanet/personal/scripts/plist.  Change each plist file’s WorkingDirectory string setting within the “[” and “]” to match your Xplanet home directory.  Seven plist files, so seven changes.  I try to keep the plist as simple as I can which for me means defining the WorkingDirectory and then defining the ProgramArguments and both Standard Paths using “./” or “../“.  The benefit of this is that you only have to hardcode the directory one time in the plist and not four, five, or six times.  This also means you cannot use the Program key and can only use ProgramArguments.

I’ll walk through an example of a plist below.  In this case, it’s the plist to update the quake marker.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

The plist header.


The label should be the name of the plist – minus the “.plist” extension – file.  These must match.


Define the working directory the script should run in.  You will need to change the [username] in each plist file (seven of them).  We unfortunately cannot reference $USER in plist files to make it automatic.


Tell the plist which script to execute and what, if any, arguments to pass to it.  I using the ProgramArguments key instead of a combination of the Program and ProgramArguments keys because the working directory is in a different location that the script and the Program key doesn’t support traversing the file system with “..”.


This tells OS X to run, not upon login, but at specified time periods.


This tells the script to run the 10th, 30th, and 50th minute of every hour.  You can also combine, for example, hour and minute times.  One key would define the hour to run and another would define the minute during that hour to run, i.e., 10:11 am.  You can see this in some of the plists in the archive I made available.


One of Apple’s launchd most powerful offerings is the ability to define specific files to capture the output of the terminal commands.  Here we define the files for the standard out path and, in our case anyway, the misnamed standard error path.  Why is it misnamed?  Well, the echo commands in the scripts get sent to the standard out path.  However, the output when we use curl to download maps and markers, gets sent to the standard error path whether or not the download is a success or failure.


These tags mark the end of the plist.

Copy the seven plist files, after you’ve made the necessary changes in each one, so that OS X can pick them up the next time you log into your Mac.  The seven plist files:

  1. Start Xplanet automatically upon login
  2. Update the Earth Map at the first of the month
  3. Update the Cloud Map at pre-defined times
  4. Update the Earthquake Marker at pre-defined times
  5. Update the Storm Marker at pre-defined times
  6. Update the Volcano Marker at pre-defined times
  7. Update the Label Marker at pre-defined times
cp ~/.xplanet/personal/scripts/plist/* ~/Library/LaunchAgents/

You can load and unload the plist files as necessary using the below commands, e.g., “launchctl load -w local.xplanet.start.plist && launchctl start local.xplanet.start“.

launchctl load -w [location of plist].plist
launchctl start [location of plist]
launchctl stop [location of plist]
launchctl unload -w [location of plist].plist

Or you can log out and then log back in.

Either way, once OS X picks up the plist, Xplanet should display as your desktop background.  If it doesn’t, go back and check the links and try everything manually.  If it works manually, then the environment isn’t getting set correctly when you try to automate the steps.


3 Responses to Automating Script Execution

  1. Vic Olivas says:

    I tried making the plist file, but when I log out and log in again, the desktop shows the Sierra desktop image. Do you know what I’m doing wrong? Terminal says that the LaunchAgent is running, and xplanet runs manually. Also, the Desktop image shows a question mark in the image field. I’m stumped. Any help would be appreciated.

    • Xplanet Blog says:

      Happy to hear that you resolved the problem. Wondering why it wasn’t working in the first place. Did you make the necessary changed in each of the plist files then place those files in your local LaunchAgents folder?

  2. Vic Olivas says:

    Actually, I solved the issue. I put the path to the .xplanet folder in /etc/paths (sudo nano /etc/paths). Then I changed the desktop image to solid grey pro ultra dark and logged out and in again and it worked!

Leave a Reply

Your email address will not be published. Required fields are marked *