Quote:
I would basically like to monitor my son and see if he spends more time surfing or writing.
|
Talk to him.
quote from Dr.Phil: If you don't talk with him about stuff that doesn't matter, you can't talk with him about stuff that matters.
Quote:
I would just like a place to start.
|
My first idea would be to (every n seconds) run ps, grep for his username and sed/awk out the duration of each process, and generate a neat report of the average lifetime of the processes.
But I've come to realise that the idea is flawed: I leave my programs running even when I'm not using them actively (i.e. they don't have focus). Which is why my system leaks memory
So, a place to start is probably to investigate how you can find out which program has focus. I guess that this would be wm-specific--I don't think X has a notion of focus.
The in my mind optimal solution would then be to install a callback hook everytime the user switches focus, get the new time, subtract the old, and add it to the time of the program switched away from.
Alternatively, just poll for current focus every n seconds.
Things to investigate: can he cheat your program with ssh w. x-forwarding and/or embedded/nested x-sessions?
---
In any case, I hope he doesn't give you his consent (everybody deserves privacy), and I hope you don't do this without his consent.
---
hth --Jonas