Display notifications when Jekyll-based operations complete

May 30, 2013

I wanted to be notified when my Jekyll-powered site finished building and syncing, and so I whipped up a silly little LaunchBar + AppleScript thing to do just that. As I’ve mentioned here before, it takes Jekyll forever to generate and deploy my site (more on that in a future post), and sometimes when I add new content I forget to check it on the site after it’s gone live (because it’s been so long since I started the process), and so this is meant to ensure that doesn’t happen.

I opted to cheat a little and crib some stuff from an earlier project—Create a simple timer using LaunchBar and AppleScript—a hack I still use multiple times a day. With that in hand, it really was just a matter of putting a few pieces together.

As explained in that earlier post, LaunchBar’s AppleScript library has a display in large type command, which displays given text in a semi-transparent window across the center of your screen, and by throwing in a delay command (with no arguments), the window persists until you click anywhere on the screen. (And yeah, this proabably could be modified with little effort to have either Notification Center or Growl handle the message.) With that in mind, the AppleScript amounted to just this:

tell application "LaunchBar"
    set announcement to "Site Updated!" as string
    display in large type announcement
    delay
end tell

Once that was complete, all that was left to do was to call the AppleScript from my Rakefile:

desc "Build site and sync"
task :update => [:build, :merge, :sync] do
    sh "osascript _announce.scpt"
end

For those curious, the "build" task calls jekyll (with certain arguments), which generates the files needed for the site; the "merge" task combines the sitemap.xml files from both of my sites (i.e., / and /photos); the "sync" task calls s3cmd and uploads any new or modified files to Amazon S3, which is where they’re hosted; and the last line invokes the AppleScript just described.

You should follow me on Twitter here