I want to log out a user via a shell script, after a delay. However, there's a few other issues:
- User does not have admin and/or root.
- Logout must complete even if screen is locked.
Currently, I'm using the shell commands below to log out:
osascript -e 'tell application "System Events" to log out'
osascript -e 'tell application "System Events" to keystroke return'
This works fine if the screen is active, but if the screen is locked, this fails, because it depends on triggering a window, and then firing an Enter keystroke. As a reminder, techniques like killing loginwindow fail because they require root.
I'm not convinced it's possible; any ideas would be much appreciated.