After upgrading to Ubuntu 14.04 the old way of binding scripts to run when locking or unlocking my screen stopped working, but after investigating using the dbus-monitor, I found that the DBus event had changed, so here is a way of doing it nowadays:
dbus-monitor --session "type='signal',interface='com.ubuntu.Upstart0_6'" | \ ( while true; do read X if echo $X | grep "desktop-lock" &> /dev/null; then custom-lock-command-here; elif echo $X | grep "desktop-unlock" &> /dev/null; then custom-unlock-command-here; fi done )