On the OmniFocus forums user psidnell asked for a script to create clickable word clouds from OmniFocus tasks. Although tag/word clouds seem to be a bit old-fashioned these days, I liked the idea. But instead of creating click-able word clouds I wanted to create an image to be used as wallpaper. That way I would always be able to see what's currently on my plate.
As there are already plenty of scripts available to create word clouds, I did not want to re-invent the wheel. So, I finally ended up using Daniel Barsotti's PHPWordCloud project and modified it to create word clouds from my OmniFocus tasks.
Follow the steps below to set everything up:
Download / Install
Retrieve Tasks from OmniFocus
The tasks to create the word cloud are queried from the OmniFocus cache. This has the advantage that OmniFocus does not have to be running. The script is roughly based on RobTrew's GeekTool scripts. It loads all tasks that are overdue, due in the next 7 days or start in the next 7 days.
MATCHES="(($STARTS < ($NOW + (7 * $DAY))) and ($STARTS >= $TODAY)) or ((t.dateCompleted is null and $DUE < ($NOW + (7 * $DAY))) and ($DUE >= $TODAY)) or (t.dateCompleted is null and $DUE < $TODAY)"
For all matching tasks the task name and the project name are stored in a temporary file.
Create and set the Wallpaper
The temporary file containing your tasks finally gets processed by the PHPWordCloud script.
/usr/bin/php -f tagcloud.php tmp.txt 1280 800
If you want to change the dimensions of the resulting image, modify the last two parameters for width and height in ofcloud.sh. As a result a new image will be created in the script folder. The image filename is ofcloudXXX.png where XXX is a random number. This was necessary to force Mac OS X to reload the wallpaper which did not work if the file name remained unchanged.
As a last step, the wallpaper will be set on your current desktop using AppleScript.
tell application "System Events" set theDesktops to a reference to every desktop repeat with aDesktop in theDesktops set picture rotation of aDesktop to 0 set the picture of aDesktop to theFile end repeat end tell
There are other solution to set the wallpaper but all of them require a restart of the Finder or the Dock which is a bit too much of a hack for me.
Automating the Process
If the script is setup correctly, it will generate a new word cloud image every time it is executed. You probably do not want to run the script manually whenever your OmniFocus data changed. So let's automate the process.
The simplest way to re-create the wallpaper after fixed amount of time is to use Mac OS X built-in LaunchAgents. If you downloaded the files from my GHitHub repo, you will find a LaunchAgent property file called com.markokaestner.ofcloud.plist.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.markokaestner.ofcloud</string> <key>ProgramArguments</key> <array> <string>/bin/bash</string> <string>/path/to/ofcloud/ofcloud.sh</string> </array> <key>StartInterval</key> <integer>600</integer> </dict> </plist>
Simply change the /path/to/ofcloud to the path you saved the script files. Copy the file to ~/Library/LaunchAgents and load it with launchctl:
launchctl load com.markokaestner.ofcloud.plist
This is only necessary for the first time. Whenever you reboot your Mac, the LaunchAgent will be loaded automatically.
The Final Result
The resulting wallpaper should not be treated as a replacement for your OmniFocus task list. But it is a nice and colorful reminder on what's currently on your plate.
There are still some things to improve. I would like to include the task due date into the weight of each tag. It is also a pity that there does not seem to exist a reliable way to update the wallpaper of all virtual desktops and screens. Ideas are always welcome...