LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to detect that the pc is currently used (keyboard/mouse use)? (https://www.linuxquestions.org/questions/linux-general-1/how-to-detect-that-the-pc-is-currently-used-keyboard-mouse-use-4175424836/)

Xeratul 08-30-2012 02:44 PM

How to detect that the pc is currently used (keyboard/mouse use)?
 
Hi,

I would like to use the pc over the ssh when no one is seated on the distant machine (CPU, ...). Not to disturb anyone.

How could, as user (no root), know that a person is sitting, using the mouse and keyboard, - sort to say working on the work station?

Who does not help much since the person could be logged in and having lunch, ...

Checking the mouse activity would be an idea, but it is not possible.Keyboard use neither.

Thank you

Ygrex 08-30-2012 04:58 PM

usually `w` provides idle-time information per terminal; also you can monitor /dev/input/event* devices (if available) in order to catch terminal activity in real time

Xeratul 09-01-2012 02:34 PM

Quote:

Originally Posted by Ygrex (Post 4768624)
usually `w` provides idle-time information per terminal; also you can monitor /dev/input/event* devices (if available) in order to catch terminal activity in real time

w sounds very good !!! thank you very much !!

maybe like this :
Code:

sleep 10s ; w | grep "w$" | awk ' { print $5  } '

I would say to monitor /dev/input/event* is more tricky + it might lead to cpu consuming.
I think about :
Code:

cat /dev... | while [ 1 ] ; do ... bla ; done

I know too xprintidle, but the problem is that is might be limited to x11 and not necesaarily in all conditions working.


All times are GMT -5. The time now is 03:56 AM.