How to detect mouse and keyboard inactivity on Linux

I am developing a python application that checks for user inactivity. Is there a way to check for keystrokes and mouse movements on Linux?

+4
source share
1 answer

You can control the files / dev / input / * when the key is pressed / the mouse is moved, it is written to one of these files.

Try this for example:

fh = file('/dev/input/mice') while True: fh.read(3) print 'Mouse moved!' 

Now that I think about it, it would be better to use something like xidle to detect inactivity.

+5
source

Source: https://habr.com/ru/post/1303324/


All Articles