For those of you with an iPhone, this doesn't really apply since you always have your tasks available via the iPhone-optimized RTM webapp (unless you're a non-pro user). For those of you with an iPod Touch, this certainly still applied when I originally created it in October due to the non-permanent nature of the device's internet connection. However, with the release of the offline-capable, native iPhone/iPod Touch RTM app (available from the app store), my approach applies to a slightly smaller audience. Nevertheless, non-pro users and owners of "regular" iPods will still definitely find this useful.
In any case, my approach was the following:
- Pull RTM tasks in ATOM format from a particular list or smart list to a temporary file
- Transform the ATOM XML to a plain text format
- Copy the plain text tasks file to the notes directory on my iPod so I can view them on my device
- Run the above three tasks in sequence with no intervention (i.e. a script)
- Run the script nicely, i.e.
- The terminal window appears in a visually pleasing way, or does not appear
- The terminal window closes after the script is run - Run the script automatically when the iPod is connected
Retrieving the Tasks
Depending on your platform, retrieving the tasks requires a slightly different utility. On Mac OS X, I retrieve the tasks using curl. On many Linux distros, it can be done using wget (which is how I did it on Ubuntu when I first started working on this).
Using curl:
curl --silent --url $TaskListURL --output $TempRawTaskFilePath
Using wget:
wget --quiet --no-check-certificate $TaskListURL -O $TempRawTaskFilePath
Since the ultimate goal was to run these apps from a script, I specified the options to suppress output (silent/quiet). wget requires the --no-check-certificate option if retrieving tasks via an HTTPS URL (which one should be). Both apps require (of course) the URL to retrieve, which is specified above in the variable TaskListURL. I also specified that the retrieved tasks should be stored to a file whose path is in the variable TempRawTaskFilePath.
The URL of the ATOM feed containing the tasks in a desired list can be obtained as follows:
- Go to Remember the Milk
- Log in, if not already logged in
- Go to your Tasks
- Select the desired list (or smart list)
- Make sure no tasks are selected
- Click the Atom link in the List tab of the floating right panel, and copy the URL from your browser's address bar, OR, if you use Firefox, simply right click on the Atom link and select "Copy Link Location" from the context menu since FF will try to add the feed to your bookmarks using its internal feed reader if you just click the link
Transforming the ATOM feed
Apache has a standards-complaint XSLT processor called Xalan. On Ubuntu, I used the C++ Version of Xalan. On OS X, I use the Java version. Either way, it is easy enough to use it from the command line once you have the ATOM data and an XSL file specifying the way it should be transformed.
Using Java version:
java -jar xalan.jar -text -in $TempRawTaskFilePath -xsl atom2plain.xsl -out $TempTransformedTaskFilePath
Using C++ version:
xalan -in $TempRawTaskFilePath -xsl atom2plain.xsl -out $TempTransformedTaskFilePath
Playing around with the XSL took some time to get the desired plain text output. It is included in the download at the bottom.
Running the tasks from a script
The above steps were easy enough to capture in a bash script. I then pulled out all of the generic parts of the script into a seperate script so I can easily repeat the task for a number of task lists (or smart lists). Finally, I created a second "runner script" to run the generic script with parameters such that I get the tasks that I want copied to my iPod.
The two bash scripts are included in the download at the bottom.
Running the script nicely
In order to have the runner script run in an unintrusive manner, I created a Terminal configuration (on OS X) that executes the script in a Terminal window that:
- starts minimized (i.e. only shows up in the dock)
- shows up mostly transparent and quite small if de-iconified
- exits when the script finishes its tasks
Running the script automatically
Finally, in order to fully automate the process, I looked for a utility that would run the script whenever the iPod was connected to my computer. The app I came across is Do Something When (DSW). It does exactly when I wanted - whenever the iPod is connected, DSW detects it and runs the Terminal configuration (which in turn runs the script).
The goods
Here is a ZIP archive containing:
- The XSL file (rtm2ipod.xsl)
- The generic bash script (rtm2ipod.sh)
- The runner bash script (run_rtm2ipod.sh)
- The Terminal configuration (term_run_rtm2ipod.term)
Further work
It would be nice if ways were found to do the following things (and posted in the comments) so that the entire flow described in this post can be realized on Linux and Windows machines as well as Mac OS X (since I have only described and created the full flow for OS X):
- Create a batch equivalent of the bash scripts (for Windows systems)
- Create the equivalent of a "Terminal configuration" - something that achieves the goals of running the script in a visually pleasing, auto-closing window that starts off minimized/iconified (for Linux and Windows systems)
- Find the equivalent of Do Something When so the script can be run automatically when an iPod is connected (for Linux and Windows systems)
No comments:
Post a Comment