4

I need to detect when a machine is going to sleep in Ubuntu 9.10 and Fedora 13. Both use UPower, so I've been looking on the "org.freedesktop.UPower" DBus bus for such signals.

I've been listening for the "sleeping" signal on the UPower bus with the following command:

dbus-monitor --system "type='signal',interface='org.freedesktop.UPower',member='Sleeping'"

When I sleep the machine (either by closing the lid, selecting "shutdown -> suspend" or sending a DBus message) I don't see a "sleeping" event.

I notice that the "Sleeping" event is sent when the "org.freedesktop.UPower.AboutToSleep" method is invoked. I can do this manually by calling:

dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.AboutToSleep

And I notice the "sleeping" signal is fired. My understanding is that anything that sleeps the PC must send the "AboutToSleep" signal before hand. It doesn't seem like this is happening. I've tried these steps on both Fedora 13 and Ubuntu 9.10 and I see the same results.

Can anyone explain what's happening or provide me with an alternative DBus signal to listen for?

Many thanks,

Paul

Paul Robinson
  • 41
  • 1
  • 3

2 Answers2

2

Your question led me to something that works here:

> annotate-output dbus-monitor --system "type='signal',interface='org.freedesktop.UPower'"
08:07:00 I: Started dbus-monitor --system type='signal',interface='org.freedesktop.UPower'
08:07:00 O: signal sender=org.freedesktop.DBus -> dest=:1.145 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
08:07:00 O: string ":1.145"
08:07:22 O: signal sender=:1.20 -> dest=(null destination) serial=189 path=/org/freedesktop/UPower; interface=org.freedesktop.UPower; member=Sleeping
08:07:41 O: signal sender=:1.20 -> dest=(null destination) serial=190 path=/org/freedesktop/UPower; interface=org.freedesktop.UPower; member=Resuming
08:08:10 O: signal sender=:1.20 -> dest=(null destination) serial=192 path=/org/freedesktop/UPower; interface=org.freedesktop.UPower; member=Sleeping
08:10:08 O: signal sender=:1.20 -> dest=(null destination) serial=193 path=/org/freedesktop/UPower; interface=org.freedesktop.UPower; member=Resuming

So as you can see I did get the signals you seem to be missing. @08:07:22 I suspended the machine, @08:07:41 I started it again. @08:08:10 I hibernated it, and @08:10:08 it was restarted again. Works flawlessly here. I did try adding ,member='Sleeping' like in your post, and that worked too (only gave me the Sleeping events).

BTW, I really like annotate-output

Peter V. Mørch
  • 812
  • 7
  • 15
1

Under Fedora14 I use the same command dbus-monitor --system "type='signal',interface='org.freedesktop.UPower'" can monitor the signal with suspend signal. Check your UPower Config.