How to determine if the screen is locked or the splash screen is active from the terminal in OS X 10.6?

Due to new Kerberos restrictions in OS X 10.6, I am working on a script that offers similar functionality to what was previously available in 10.5. Basically, it analyzes the klist output to see if your ticket expires and shows how long it will expire. If we hit the 10 minute mark, it will call kinit to perform a GUI password prompt to ask for your kerberos password. If the ticket has expired, it does the same.

The script makes sure that kinit is not running before calling it again, so we don't have multiple kinit calls and the script works fine (called from GeekLog so you can see the status). The problem is that this morning my system gave a spinning beach ball when I opened the screen. I suspect my script and / or kinit is doing something; the machine was pinged but otherwise not responding to ssh or AFP.

So what I want to do is determine if the screen is locked or the screen saver is closed. I found that in previous versions of OS X you could grep the ScreenSaverEngine to determine if it was active or not, but it doesn't seem to be the case.

So how can I determine if the screen is locked or otherwise engaged using command line tools? If the screen is locked, I want the script to just exit so that it doesn't bother with klist or try to kinit. I hope this will prevent the blockage I experienced this morning. Any ideas?

+2


source to share


2 answers


A bit shred, but you can easily request a background app System Events

through Apple Events to see if the screen saver is working. For example:

$ osascript -e 'tell application "System Events"' \
>  -e 'get running of screen saver preferences' \
>  -e 'end tell'
false
$ # engage screen saver after starting next command
$ sleep 5; osascript -e 'tell application "System Events"'  -e 'get running of screen saver preferences'  -e 'end tell'
true
$

      



You probably really need to figure out why you are locking the lock.

+4


source


Just out of curiosity, did you try ssh'ing into an OS X machine and compare the process list before / after the screen saver / lock?



What would I try.

0


source







All Articles