Linux 上的用户空闲时间在 30 秒后重置为 0

发布于 2024-10-12 16:08:45 字数 941 浏览 5 评论 0原文

我正在尝试使用 X11 屏幕保护程序扩展客户端库检测自上次用户输入以来的时间。我定期调用 XScreenSaverQueryInfo 来获取空闲时间。我面临的问题是,每 20-30 秒后,此调用报告的空闲时间就会重置为 0。即使当时没有实际的用户输入,也会发生这种情况。我对此完全感到困惑。我唯一的线索是,如果我卸载 gnome-screensaver ,问题就会消失。我的问题是,gnome-screensaver 是否出于某种原因模拟用户输入?我知道这听起来不太可能,如果确实如此,那肯定是 gnome-screensaver 的错误,但我现在想不出其他任何东西。有谁知道我可以在哪里找到有关 gnome-screensaver 如何工作以及它如何影响 XScreenSaverQueryInfo 调用的更多信息,而无需实际查看代码。我已经浏览了 gnome-screensaver home 上的信息,但找不到任何内容与我的问题相关。

更新:我从 dbus-monitor 获得以下输出。我如何解释这一点:

method call sender=:1.97538 -> dest=org.gnome.ScreenSaver serial=3 path=/org/gnome/ScreenSaver; interface=org.gnome.ScreenSaver; member=SimulateUserActivity

我认为某个进程正在要求 gnome-screensaver 模拟用户活动。或者,gnome-screensaver 是否向 dbus 发送 SimulateUserActivity 信号?如果是第一个,我如何找出哪个进程要求 gnome-screensaver 执行此操作?

I am trying to detect time since last user input using the X11 Screen Saver extension client library. I make periodic calls to XScreenSaverQueryInfo to get the idle time. The problem I am facing is that after every 20-30 seconds the idle time, as reported by this call, resets to 0. This happens even though there has been no actual user input in that time. I am totally puzzled by this. The only lead I have is that the problem disappears if I uninstall gnome-screensaver. My question is, does the gnome-screensaver simulate user inputs for some reason? I know it sounds unlikely, and if it does, it will most definitely be a bug with gnome-screensaver, but I cannot think of anything else right now. Does anyone know where I can find more information on how gnome-screensaver works and how it influences the XScreenSaverQueryInfo call without actually having to go through the code. I have gone through the info at gnome-screensaver home but could not find anything relevant to my issue.

Update: I got the following output from dbus-monitor. How do I interpret this:

method call sender=:1.97538 -> dest=org.gnome.ScreenSaver serial=3 path=/org/gnome/ScreenSaver; interface=org.gnome.ScreenSaver; member=SimulateUserActivity

I think some process is asking gnome-screensaver to SimulateUserActivity. Or, is gnome-screensaver sending a SimulateUserActivity signal to dbus? If it is the first, how can I find out which process is asking gnome-screensaver to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

始于初秋 2024-10-19 16:08:45

程序(视频播放器在播放视频时执行此操作)可能会发送 gnome-screensaver-command --poke 命令,该命令将发送 SimulateUserActivity 事件来重置空闲时间,将阻止屏幕保护程序激活。

A program (video players does this while playing video) might be sending a gnome-screensaver-command --poke command which will send a SimulateUserActivity event to reset the idle time which will prevent screensaver becoming active.

怪我太投入 2024-10-19 16:08:45

一旦您拥有 dbus 发送器(如 dbus-monitor 所示),您可以执行以下操作:

dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetConnectionUnixProcessID string:':1.97538'

插入实际的发送器。这将为您提供发送消息的 pid。

然后假设 pid 是 2144,你会这样做:

cat /proc/2144/cmdline

作为查看程序是什么的一种方法。

Once you have the dbus sender (as shown on dbus-monitor there) you can do:

dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetConnectionUnixProcessID string:':1.97538'

plugging in the actual sender. That gives you the pid that's sending the message.

Then say the pid is 2144, you'd do:

cat /proc/2144/cmdline

as one way to see what the program is.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文