Do you know what dbus runes to use to see if the screen is currently locked?
Nokia-N900:~# dbus-send --system --print-reply --type=method_call --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.get_tklock_mode method return sender=:1.8 -> dest=:1.199 reply_serial=2 string "unlocked"