PDA

View Full Version : Catch power events (suspend, resume) on linux



Ginsengelf
8th April 2015, 16:56
Hi, on Windows I implemented QWidget::winEvent() and process the power events (suspend, standby, resume; using WM_POWERBROADCAST) there. This works quite well.
Now I need to implement the same functionality under linux. I looked at QWidget::X11Event(), but it seems that XEvent does not handle power events like standby or resume.

Did I overlook something? Or is there another way to catch power events on linux?

Ginsengelf

yeye_olive
8th April 2015, 17:59
The closest to a standard API you can get on Linux desktops probably is UPower (http://upower.freedesktop.org/), which is exposed as the D-Bus interface org.freedesktop.UPower. It features a few interesting signals, such as Sleeping() and Resuming(). See the documentation of Qt D-Bus to know how to interface them with your application.

anda_skoa
8th April 2015, 19:55
If you are looking for a Qt API, have a look at Solid: http://inqlude.org/libraries/solid.html

Cheers,
_