I am looking a way for a script (either bash or AppleScript, doesn't matter) to detect whether the state of either the screen or the user login session is locked or not (i.e. the user will need to type in its credential to get back to her/his session).
This is different than detecting whether screen saver is on, which is already answered in http://stackoverflow.com/questions/1390123/, as active screen saver is not always the same as locked session.
Do you have any suggestion? Thanks!