如何在 Linux 中检测鼠标和键盘不活动
我正在 python 上开发一个应用程序,它将检查用户的不活动情况。有没有办法检查Linux中的按键和鼠标移动事件?
I am developing an app on python which will check for user inactivity. Is there a way to check for key press and mouse move events in linux?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以监视 /dev/input/* 文件,当按下某个键/移动鼠标时,它会被写入这些文件之一。
试试这个例子:
现在我想到了,最好使用 xidle 检测不活动状态。
You could monitor the /dev/input/* files, when a key is pressed/the mouse is moved it is written to one of those files.
Try this for example:
Now that I think of it, it might be better to use something like xidle to detect inactivity.