Automatic upload of Safari bookmarks

I use Safari as my primary browser on my laptop, but often browse the web from other computers, and I like having my bookmarks up to date. This describes how I use launchd to update my website whenever I change my bookmarks in Safari.

Generating Links page

So the first step is the script which grabs the bookmarks from Safari and converts them into a webpage. For this I have a script which reads the ~/Librfary/Safari/Bookmarks.plist and formats into HTML. This script relies on the Python<->Objective-C bridge to parse the bookmarks file.

Upload script

I have a simple one-line shell script which runs the runs and uploads the result to my website:

/Users/benno/local/bin/ | ssh "cat > public_html/links.pml"

Setting up launchd

launchd is the new uber-daemon in Tiger, which allows users to register their own tasks to be run automatically. There are various triggers that can be used to fire off a task, but the one we are interested in here is WatchPaths, which fires when a particular path is modified.

User tasks are stored in ~/Library/LaunchAgents. I created a file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">

<plist version="1.0">




The Label field identifies the task. We use the reverse dotted notation to avoid any possible namespace clashes. The WatchPath key specifies a list of paths to watch, in this case we care about Safari's Bookmarks.plist. Finally the Program specifies what to run when the event is triggered, in this case the shell script shown above.


Launchd makes it simple to automate tasks on OS X, and when combined with PyObC allows for some powerful scripts to be written.