I’m a fan of simple applications and text files, especially for organization, so I enjoyed Hog Bay Software’s [Taskpaper](http://hogbaysoftware.com/products/taskpaper) when it first came out. I quit using it after a while because I used some non-Mac computers, and wanted a web component to get to it anywhere. I missed it, and this week, I moved back to after I wrote a script to sync my TaskPaper files to Tasko. I got to use OS X’s [LaunchDaemon](http://en.wikipedia.org/wiki/Launchd) for the first time, and the Ruby XML-RPC library, and I thought I’d share how I did it.

I have a Tasks/ directory under my home directory. You can use whatever directory you want, but it’s assumed you have a directory with one or more .taskpaper files in it.

I wrote a Ruby script, taskosync, to sync that directory to Tasko ([get it at pastie](http://pastie.org/227518)). This isn’t my best code, but it’s OK for a little script. Here’s its logic:

This ends up working in almost all cases. If you add a file online, TaskoSyncer will note that you didn’t have it locally, so it will know to grab it. Likewise, if there’s a file online that isn’t local, but it used to be, TaskoSyncer will know to delete the online one.

So, this is pretty good on its own, but wait! launchd makes this way better. Here’s a .plist file I wrote and saved at /Library/LaunchDaemons/org.cnixon.taskosync:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
    "http://www.apple.com/DTDs/PropertyList-1.0.dtd>
<plist version="1.0">
  <dict>
     <key>Label</key>
     <string>org.cnixon.taskosync</string>
     <key>ProgramArguments</key>
     <array>
        <string>/Users/cnixon/bin/taskosync</string>
     </array>
     <key>RunAtLoad</key>
     <true/>
     <key>WatchPaths</key>
     <array>
        <string>/Users/cnixon/Tasks/</string>
     </array>
  </dict>
</plist>

Whenever any contents in my Tasks/ directory change, it syncs. Since it ignores non-.taskpaper files, I can force sync by touching an empty file in there, although it’s just as easy to run taskosync from the command line.

View the forum thread.

blog comments powered by Disqus