Trying to get idle time in Lion

the shell script command I’ve been using forever to get system idle time had decided to stop working in Lion. Anyone have a solution to this yet?

set idleTime to (do shell script "ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle,\"\";last}'") as integer

Try this…

delay 5
(do shell script "ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print $NF/1000000000; exit}'") as integer

thank you, I will try it in the morning

I don’t know what the script is returning but it is not idle time. The number that is being returned is always increasing. I started with a five second delay, ran the script four times and got 908 917 925 933, then changed the delay to three seconds and got 944 951.

sorry, any other suggestions?

I run it and get 5… so I’m not sure what’s happening on your machine.

and you are running Lion?

I just ran it on five different computers running Lion. I was getting values in the 6000-7000 range increasing each time I ran the script.

I restarted one of the computers and re-ran the script and it started out in the double digits. I wonder if it is returning up time.

I’m getting 5, and I’m running Lion.

thanks, that’s totally strange. These computers have only a fresh Lion and iLife 11 installed in them.

Only thing I can think of is I am using Apple Remote Desktop to remote in and test the script. I’ll try running it sitting in front of the computer in the morning.

Do over. I will keep everyone updated.

And that was it! I get these really high numbers when I am remoted into the computer. When I run the script sitting in front of the computer the result is always 5.

Just doesn’t seem like it should make a difference. Now I have to figure out if this affects the script if I am activating it on the remote computer via ARD.

Update: the script works fine being executing remotely via ARD