Forecast.io Weather on the Mac Desktop
Because I could.When I saw that the excellent weather service forecast.io released a feature called Forecast Embeds, I thought it would be neat to show the widget directly on my Mac’s desktop. I whipped up a solution that ended up looking like this:
Read on to learn how get Forecast Embeds up and running on your Mac’s desktop.
Dependencies
- GeekTool, NerdTool, or any other tool that can display an image directly on the desktop
- The following command-line utilities, all of which are available via Homebrew on OS X:
forecast_snapshot.sh
, a simple shell script I wrote
How it Works
- On a reasonably slow interval, the
forecast_snapshot.sh
script automatically takes a screenshot of the Forecast Embeds page with the latest weather data, and stores that screenshot on the filesystem. It then does some image processing on the screenshot to make it look more attractive when overlaid onto a wallpaper. - On a reasonably fast interval, the screenshot is automatically [re-]displayed on the desktop.
Getting it Going
-
Install the dependencies listed above, and grab a copy of the
forecast_snapshot.sh
script. -
Edit the variables in
forecast_snapshot.sh
to your liking.You’ll need to provide the latitude/longitude for your area, which you can find using a service like latlong.net. There are several available options that aren’t part of the script, but can be added to the Forecast Embeds URL in the script. See the Forecast Embeds documentation for details.
-
Run
forecast_snapshot.sh
and verify that the image file/tmp/weather-full.png
is created on your system, and contains the font/text/weather information you expect. -
Embed the
/tmp/weather-full.png
image on your desktop using GeekTool (or your tool of choice.) I configured GeekTool to refresh the image every minute. -
Make
forecast_snapshot.sh
automatically run on an interval (15 minutes seems reasonable). You can do this via GeekTool orlaunchd
. -
You’re done.
Final Thoughts
Forecast Embeds are simple web pages that include animations, so the sceenshots that are taken will inevitably catch the animations mid-frame. If you prefer to keep the animations working, you can use something like Fluid to float the Forecast Embeds page on your desktop as its own app, but it won’t be transparent and thus won’t blend in with your wallpaper.
Tags: automationmactools