System idle time under Linux
John Pinner
funthyme at gmail.com
Thu Sep 30 05:26:23 EDT 2010
On Sep 29, 7:36 pm, Hugo Léveillé <hu... at fastmail.net> wrote:
> Good point
>
> One I am looking for, is time since last user mouse or keyboard action.
> So I guess I am looking for the exact same thing a screensaver is
> looking for
The command
who -Hu).
will give you idle time for each logged-in user
( H - print headers; u - list users )
and you could run this command via subprocess, then read and parse its
output.
Alternatively you could parse the same file(s) as who - I think it
reads /var/run/utmp - but that would be a lot more work, as it is a
binary file (run man utmp to see its format, use the struct module to
decode)
Best wishes,
John
--
More information about the Python-list
mailing list