Time Remaining on an Energy Saver (or pmset) setting

If I use this AppleScript command:

do shell script sudo pmset dim 5 password myPW with administrative privileges

to set the screen sleep time to 5 minutes, for example, a register somewhere must count down 300 seconds from the time the script executes.

Does anyone know where that timer value is kept? Is it accessible to a shell script command, i.e. can I ask “how much time is left before the screen sleeps” and get an integer value back? I actually want to use this to see how long the screen has been awake, knowing the pmset value for dim.

I thought there might be a gestalt attribute to get this value but I struck out. I did stumble onto
http://developer.apple.com/qa/qa2004/qa1340.html
but this is way out of my league!

Mine too, but thanks. After reading it, I didn’t see how it would give the time remaining, only a short warning of impending sleep.