Weather Integrated into Wallpaper: A GeekTool Widget for Mac OS


You will need:

GeekTool is an application available for Mac OS that allows the user to create widgets embedded in their desktop.  These widgets commonly display time, date, to do lists, weather information, and images.  I’ve played with GeekTool on and off over the years — sometimes using it for practical reasons, like an easily visible record of uptime on older machines, and sometimes for frivolous ones, like the GeekTool I’m going to share with you today.

While displaying weather widgets with images is a common GeekTool, I have yet to see one integrated into a desktop image, so I decided to give it a try.  To accomplish this, you’ll needed to use two GeekTools, one image and one shell.  I used two small scripts, one written in bash and the other a line in python, but you could easily write all of this in one script, splitting it up was just faster for me in the moment.

To start, you’ll need a desktop-sized image with a features you can easily crop out to overlay on your weather conditions images.  I decided to use the below photo of midtown Manhattan with Brooklyn and Queens in the foreground, as the singular cloud makes for creating an extra layer much easier (and yes, it was a real cloud).  Original photo by Jeff Weston, who reports catching the shot as his plane landed at Laguardia.


I copied the large triangular cloud into a separate image file using Photoshop, and placed this image file in an image GeekTool directly over the cloud in the desktop image.  You’ll notice in some places, like the lower left edge, I’ve done a lazy job selecting the edges of the cloud: these are places where the weather condition images would not be showing, and therefore the edge would blend in regardless of my cropping job.


Once you have the image to overlay on your desktop, you’ll need the images for weather conditions that will display between this image GeekTool and your actual wallpaper.  To know how many images and of what kinds of weather you’ll need, you need to decide where you’ll be taking your weather information from.  I decided to use Wunderground to gather weather information, so I needed to find out what they name their basic image files for weather conditions.

From here on, you’ll want to take a look at the weatherGeeklet repository on my GitHub to find the two pieces of code I will reference.  The first part of the bash script I wrote pulls current weather information based on airport codes.  This isn’t perfect, given that many people live over a hundred miles from their nearest airport, but when in or near a metro area, it works just fine.  The line below copies all information from the url given into an XML document for refernce by the rest of the script.  Replace BDL in the URL with your airport code for weather in your area.

curl -s > weather.xml

I used this at the command line for a few different cities until I found the names for most of the possible weather conditions.  Wunderground’s simplest weather condition codes are found between the <icon> tags.  They use clearpartlycloudymostlycloudyrainsnow.  For the time being, I have decided to use the same image for partlycloudy and mostlycloudy for now.

Once you have the basic values for the various weather conditions, you’ll need to make image files for each of them.  I took the basic pieces of the images from Wunderground and editted them to fit the cloud and my liking, placing them in equal sized image files with transparent backgrounds.  Positioning the weather conditions relative to each other is a little tricky, as you want “partly cloudy” to show the sun slightly behind the cloud, and “rain” to be coming from underneath the cloud, and both of these files must be placed in the same position on the desktop as they are all part of the same GeekTool.

Now that you have your weather conditions images made and properly named after the weather conditions present in the <icon> tag or equivalent tag, you’ll need a shell script that calls the corresponding image for the value in this tag.  The bash script I wrote copies the image file with the name that matches the current weather conditions to the file named current.png.  The shell GeekTool then displays current.png and refreshes every five minutes (as does the bash script).  For more on the bash and python scripts I used, see the ReadMe in my GitHub repository.

Here’s how the GeekTool looks when running on my machine:



Partly Cloudy

Screen Shot 2014-04-10 at 10.26.42 PM

From these screen shots you can also see I’ve included the current outside temperature in Farenheight on the United Nations Secretariat Building, and the day of the month in large font in the bottom right corner.  I realize with the menu bar, I have cropped the top of the photo very close to the top of the cloud, but I wanted as much Brooklyn and Queens in the view as possible, since my family is from Brooklyn (my grandfather was actually born on a kitchen table on Avenue O).

I am in the process of perfecting my snow image file so that the snow falls nicely on the Empire State Building, so I’ll post a future update of this GeekTool when I touch up that image as well as add a white indicator bar for humidity level to the Trump Tower.  If you have any suggestions for other things I should add, I’m very open to hearing ideas.

This GeekTool takes quite a bit of customization to get it working properly, and so simply downloading my image files may not yield my exact results.  If you download my scripts and put them to use, I’d be interested to hear how it works for you.  Leave a comment and let me know!


Add a comment

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

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

Google photo

You are commenting using your Google 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