Linux/Python:无需轮询即可监视 /proc/acpi 文件?

发布于 2024-08-23 22:26:00 字数 277 浏览 5 评论 0原文

有什么方法可以监视 /proc 文件,例如

/proc/acpi/battery/BAT0/state
/proc/acpi/ac_adapter/ADP0/state

以非轮询方式,类似于普通文件系统上的 inotify ?

我想在 PyGTK 应用程序中执行此操作,因此我尝试使用 PyGObject 的 gio.FileMonitor,但没有骰子。与 gtk.main() 配合良好的 Python 解决方案将是理想的选择。

Is there any way to monitor /proc files, such as

/proc/acpi/battery/BAT0/state
/proc/acpi/ac_adapter/ADP0/state

in a non-polling fashion, similar to inotify on a normal filesystem?

I want to do this in a PyGTK app, so I tried using PyGObject's gio.FileMonitor, but no dice. A Python solution that plays well with gtk.main() would be ideal.

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

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

发布评论

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

评论(1

一城柳絮吹成雪 2024-08-30 22:26:00

也许您可以通过监听 ACPI 事件来获取您想要的信息。最好不直接(/proc/acpi/event),而是通过 acpid 或其他高级接口。

更新:另一个更高级别的接口是DeviceKit-power / UPower 提供的DBus 接口。

/proc 中的文件不是常规文件,而是内核状态的简单接口,因此常规文件的许多功能在那里不起作用。

Probably you can get the information you want by listening to the ACPI events. Preferably not directly (/proc/acpi/event), but via acpid or other high-level interface.

Update: the other, higher level interface is the DBus interface provided by DeviceKit-power / UPower.

Files in /proc are not regular files, rather a simple interface to kernel state, so many facilities for regular files won't work there.

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