It's not Active Desktop Calendar, but it'll work (Mac)

I bought a MacBook Pro a few months ago because I needed a new laptop for work and was intrigued by the Apple line, after reading a bunch of great reviews from .NET developers who had made the jump.  After a few months of use, I really began to the love thing and considering it has more computing power than my current home desktop setup, I decided I wanted to shift my use to the MacBook Pro completely and ditch the desktop altogether.

So I've been spending the past few weeks making sure any program I use regularly on Windows has a Mac counterpart and I've managed to get pretty much everything I needed.  However, one little Windows application that I use all the time, Active Desktop Calendar, did not have any Mac equivalent that I could find.

It's such a simple application - you put events in a calendar that sits in your system tray and it displays them down the right side of your screen.  But it became so indispensible to me - I entered all the Flyers games in there (I'm an avid fan), all the upcoming concerts in the area I wanted to go, birthdays, parties, family events, etc.  It got to the point where I had to look at the thing before giving someone a "yes" or "no" about whether I could make an event to see what else was scheduled.  And I loved that I could just see it - I didn't have to open a program or anything.  It was just always floating there.

I wanted similar functionality on my Mac.  And I couldn't find anything out of the box that took care of it.  Until one day, I saw this post about this post on Lifehacker.  Now the ball was rolling.  I liked that it displayed freely on your desktop, but wasn't a fan of the calendar-like format.  It seemed a bit excessive and took up a little too much screen real estate for my liking.  So I downloaded the script and decided to take a look.

I had never worked with AppleScript before, but I figured now was a good time to dive in.  The syntax is pretty easy to pick up, especially if you have some programming background.  And I spent some time cleaning up the code to do what I wanted it to do - instead of creating files to be read into the Remind program, I just created text files formatted the way I wanted to display on desktop using GeekTool alone.  I also found a few ways to speed up the script - it grabbed all the events in a calendar, whereas I made it grab only events with a date that was either today or in the future.  And I made a few other tweaks to my liking.  My script can be downloaded here.  WARNING:  It's a work in progress and I actually have a bunch of additions/changes planned for it now.

The one major problem with this script is that it doesn't run automatically.  Every time you updated your iCal, you'd have to go run this script to get the changes to show up.  Not my idea of user-friendly.  So I set about trying to figure out get this thing to run on a schedule and came across launchd.  You use configurable plist files to schedule pretty much anything on our Mac.  It took me a bit to figure out how to get this thing working (where do I put the plist files? can I use relative pathing or must it be absolute) but I finally did and now I have it running where the script runs once every hour.  There are some advanced features where you can set WatchPaths and have launchd run your commands based on whether or not a folder, or any files in that folder, have changed.  I'm putting that on my TODO list for this application - I'd love to have it run after I enter a new item into iCal, instead of on a timed basis.  That would be beautiful.

Anyway, here is the plist file I created (turns out - absolute paths are necessary):
<?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>Debug</key>
    <false/>
    <key>Label</key>
    <string>com.apple.iCalToDesktop</string>
    <key>OnDemand</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/Users/*myusername*/Documents/Calendars/iCalToDesktop.scpt</string>
</array>
<key>StartInterval</key>
<integer>3600</integer>
</dict>
</plist>


I think it's pretty self-explanatory (now that I have it working - I was ready to pull my hair out for a day or two haha), but if you have any questions, please don't hesitate to get in touch.

You put that file in your User/*username*/Library/LaunchAgents folder. Then open a terminal and run:

launchctl load *path to that plist file*

You have to log out of your account and log back on before the schedule starts running though.

So once you have that going and you want to display your text files on your desktop using GeekTool, it's pretty elementary. Just open GeekTool, create a new entry of type "Shell" and enter this:
cat *path to text file you want to display*

If it worked, you should see the contents of the file display on the desktop with a rectangle around them. You can position this rectangle by dragging it to wherever you want on the screen, and make it whatever size you want.

So now I have my precious events showing up on the desktop like I had with Active Desktop Calendar and it's even more of a benefit because it uses iCal which will also sync with my iPhone and whatnot. Pretty sweet.

I know this post lacks a lot of detail about the code itself, but if you open it, you'll see that the syntax is pretty easy to follow. Of course, if you have questions/comments/suggestions/improvements, please don't hesitate to get in touch. And I want to stress that the base of my code was taken from this blog post so this guy deserves a bulk of the credit. I sorta just took his framework and updated it for my own personal needs.

A few improvements I'm planning for when I get some more time:
  • Adding the TODO list items from iCal
  • Further formatting of each individual calendar (I have different calendars for concerts, Flyers games, birthdays, etc.)
  • Adding the ability to read the repeat type of an event (daily, weekly, monthly) and displaying them accordingly
I'm sure more stuff will come to mind once I start seeing what I like and don't like about my current setup.