Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Detecting idle time on Mac

by Fletch (Bishop)
on Sep 14, 2006 at 12:31 UTC ( [id://572916]=note: print w/replies, xml ) Need Help??


in reply to Detecting idle time on Mac

Google is your friend.

ioreg -c IOHIDSystem | perl -lane 'if(/Idle/) {print $F[-1]/1000000000 +; last;}'

Update: cleaned up that link's Perl version a bit.

Replies are listed 'Best First'.
Re^2: Detecting idle time on Mac
by sgifford (Prior) on Sep 14, 2006 at 13:12 UTC
    Thanks Fletch, looks like that will work! For some reason I didn't think to search for OS X; I had been searching for Mac keyboard idle time and similar, which strangely turned up nothing.

    Does anybody happen to know of a way to get this information without forking a copy of ioreg?

    Thanks!

      There should be some way to access it through C and/or ObjectiveC, but exactly how is a different question. The Apple Developer Site has a pretty good set of documentation; you'll probably want to start looking here for stuff on I/O Kit and the HID related frameworks.

      Unless this is something that's going to poll constantly I'd just cheat and run ioreg; it only takes six hundredths of a second to run according to my shell's timeing.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://572916]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-25 06:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found