What Upower DBus Signal is Emitted when Screen is Turned On or Off

Mystilleef mystilleef at gmail.com
Tue Apr 24 04:18:42 PDT 2012


On Tue, Apr 24, 2012 at 6:18 AM, Martin Pitt <martin.pitt at ubuntu.com> wrote:
> Hello Mystilleef,
>

Hello Martin!

Thanks for your response.

> Mystilleef [2012-04-24  4:22 -0400]:
>> What upower dbus signal do I need to listen to when my
>> laptop screen is turned on or off by gnome-screensaver or
>> gnome-power-manager?
>
> None. This is not the domain of upower, nor kernel uevents. This is
> not even an XRandR event (which also sends notifications, but
> different ones). I believe gnome-screensaver just uses the equivalent
> of "xset dpms force off" (through a library interface).
>
> However, I am not aware that DPMS provides notifications, and [1] and
> its lack of responses do not rise my hopes.
>

I pray this is not so. And if it is, then it is embarrassing
since every other platform I know off (windows, mac,
android, iphone), provides signals for when the screen is
turned on/off. In my presumptuous mind, I like to believe
Linux is superior to most of those platforms. :-)

>> The solution I've found so far is to run a script that
>> resets the screen after a resume operation. Placing the
>> script in /etc/sleep.d does the trick.
>
> Indeed that is the recommended approach.
>
>> However, this doesn't work when resuming the screen alone from
>> sleep.
>
> So I take it this "sleep" is not "suspend to RAM", but you mean
> "switching off the monitor on idle"?
>

Yes! Sorry for the confusion. GNOME Screensaver, I think,
turns off my screen, as a power saving measure, a few
seconds after the screensaver is activated and locked. About
5 minutes later the laptop is suspended to RAM.

My problem is __before__ the laptop is suspended to RAM and
when the screen is completely powered off. If I move the
mouse, or touch the keyboard, to wake the screen, I get the
screen corruption I described earlier. Bear in mind that at
this point the laptop is not yet suspended to RAM. So the
scripts in /etc/sleep.d/ do not run.

I was hoping for something like a /etc/dpms.d/ folder where
I can run my script when the screen is woken up before the
laptop is suspended. Or a signal that alerts me when the
screen is turned on or off.

At the moment, I'm using the "ActiveChanged" DBus GNOME
Screensaver signal. It doesn't work properly. The signal
gets emitted when the screensaver is (de)activated but not
when the screen is turned on or off. So I have to type my
password blind to unlock the screensaver before my script is
run.

GNOME Power Manager used to have a DPMS signal a few years
ago. Currently, it looks like the DBus API for GNOME Power
Manager has been scrapped. I'm thinking if GNOME Screensaver
is responsible for turning on/off the screen perhaps it can
emit a signal after those operations?


More information about the devkit-devel mailing list