Final Thoughts

xplanetFX

xplanetFX on macOS (macOS 10.10+ only)

xplanetFX, developed by Markus Schmidt, is a collection of scripts that manipulate the Xplanet rendering with lighting effects for Linux environments. The scripts utilize command line binaries like Xplanet, ImageMagick, wget (which Apple no longer includes with macOS), date, and sed.  While Apple does ship with date and sed, they differ from the GNU versions the xplanetFX scripts are built around.

While xplanetFX is no longer seeing any active development, we can still get it to work… for now. It is built around Python 2 never upgrading to 3. Homebrew, rightfully so, has started to remove older formulae that rely on Python 2. I end up hosting the formulae on my tap that are necessary to get xplanetFX to run.
brew tap blogabe/xplanet
brew install blogabe/xplanet/xplanetfx [options are optional]
xplanetFX --gui

You can choose to compile all the dependencies xplanetFX requires from source. I prefer to use bottled versions of the dependencies, when we can, rather than building them from source. I haven’t seen a benefit of building the dependencies from source.

I set the formula that installs xplanetFX to mimic what it looks like in a Linux environment as it was configured to do, i.e., it’s not necessary to include or exclude any build options. However, you have the option to do so if you prefer.

Display Xplanet Image on Secondary Screens

Let’s use Rogan and Hari’s comments at the bottom of the Scripts page to save the Xplanet renderings and display them to either your primary or non-primary screens.  There are two ways to go about this.  One would be, per the comments, to delete the last image before Xplanet updates.  The other would be to save the images in an output directory and symbolically link to the most current image.  I’m going to show the latter because, to me, if you’re going to go through the trouble outputting the file and saving it somewhere, you might want to animate the images using mencoder.  This way will obviously take up a lot more disk space – ~2 GB / wk assuming continuous five minute updates – so you’ll want to delete files older than, say, 36 hours.

We need to create two output directories: one to store the Xplanet images, and the other to store the symbolic link for OS X to reference.  We’ll need a set of these directories for each monitor we want to draw to (let’s assume three with varying ratios).
cd ~/.xplanet
mkdir -p output/{display1-1920x1080,display2-1920x1080,display3-1680x1050}
mkdir -p ~/Pictures/{XplanetDesktop1,XplanetDesktop2,XplanetDesktop3}

It’s probably a good idea to edit the xp.def file as well and specify the geometry of each screen.

...
XPLANET_GEOMETRY1=1920x1080
XPLANET_GEOMETRY2=1920x1080
XPLANET_GEOMETRY3=1680x1050
...

Next up is to change the Xplanet startup in the xplanet.sh script.  You’ll probably want to add some logic to use a different config file or different command line options.

...
start)
  SCREEN=$2
  SCREEN_TEMP=XPLANET_GEOMETRY${SCREEN}
  SCREEN_GEO=${!SCREEN_TEMP}
  OUTPUT=Screen$SCREEN-$SCREEN_GEO-$(date +"%Y%m%d.%H.%M.%S").png
  $XPLANET_BIN \
    -searchdir=$XPLANET_HOME \
    -config=$XPLANET_CONFIG/xp.conf \
    -projection=$XPLANET_PROJECTION \
    -longitude=$XPLANET_LONGITUDE \
    -labelpos=+10-45 \
    -date_format="%D at %r" \
    -color=green2 \
    -geometry=$SCREEN_GEO \
    -output=output/display${SCREEN}-${SCREEN_GEO}/${OUTPUT} \
    -num_times=1
  find output/display${SCREEN}-${SCREEN_GEO}/ -mtime +36h -delete
  rm ~/Pictures/XplanetDesktop${SCREEN}/*.png
  ln -s output/display${SCREEN}-${SCREEN_GEO}/${OUTPUT} ~/Pictures/XplanetDesktop${SCREEN}/${OUTPUT}
  echo "$(date): Xplanet ran for display ${SCREEN}"
;;
...

To automate this, we’ll need to copy the local.xplanet.start.plist file for each screen, e.g., local.xplanet.start1.plist, local.xplanet.start2.plist, and local.xplanet.start3.plist and make some minor changes.  Be sure to change the Label key as well.  It’s not below, but it is imperative the Label and file name match.

ORIGINAL PLIST:
...
<key>ProgramArguments</key>
<array>
  <string>./config/scripts/xplanet.sh</string>
  <string>start</string>
</array>

<key>RunAtLoad</key>
<true/>
...

NEW PLIST:
...
<key>ProgramArguments</key>
<array>
  <string>./config/scripts/xplanet.sh</string>
  <string>start</string>
  <string>[DISPLAY # - MUST MATCH NUMBER USED IN PLIST]</string>
</array>

<key>StartInterval</key>
<integer>300</integer>
...

Last step is to open up Desktop & Screen Saver in macOS System Preferences.  For each display, point to the respective directory holding the symbolic link under ~/Pictures, and change the background setting to 5 minutes.  You can do this not just for the physical displays, but also for the individual spaces within each physical display (where one screen can house multiple virtual desktops).

Making a Movie

And a little something extra.  Let’s create a movie using mencoder.
brew install mplayer
cd ~/.xplanet/output/[specific display sub-folder]
ls *.png > stills.txt
mencoder mf://@stills.txt -nosound -ovc lavc -lavcopts \
  vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o xplanet.avi -mf type=png:fps=24

This will output two hours worth of 5 minute stills each second – 24 frames per second – so a movie showing one day’s worth of renderings taken every 5 minutes will be 12 seconds long.

2 Responses to Final Thoughts

Leave a Reply to Ziuve Cancel reply

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