GNOME Bugzilla – Bug 344979
Inhibit Gnome Power Manager from suspending while playing
Last modified: 2006-10-02 10:59:13 UTC
From: https://launchpad.net/distros/ubuntu/+source/rhythmbox/+bug/49260 All rhythmbox has to do is call a simple dbus method when playing starts and a simple dbus method when it's paused or stopped. This way Gnome-Power-Manager doesn't auto-suspend or power-down while music is playing. See https://wiki.ubuntu.com/GnomePowerManagerInactiveSleep for more information.
should this be in the tree itself, or a plugin?
I would have thought in the tree itself, but I imagine the person requesting a feature usually does ;)! The extra code is small, so it would be excellent if it "Just Worked" for all the people that didn't think about it.
*** Bug 348088 has been marked as a duplicate of this bug. ***
Created attachment 72372 [details] [review] power manager plugin Simple plugin that calls g-p-m's inhibit/uninhibit methods when playback starts/stops. It's hidden and enabled by default, so no one needs to know it's a plugin at all. Doesn't seem to do any harm when run on a system with no g-p-m installed.
Looks nice. Just some nitpicks you can ignore if you like :) Looks like indentation is inconsistent in the schemas. The cookie should be a guint32. In most places you explicitly test for NULL eg: "if (plugin->proxy == NULL)" Which I think is good so that when reading the code you know without looking elsewhere that the value is not a boolean. However you check "if (error)" in a couple places. Yeah pretty anal but in my experience it helps. Richard should fix his example code I guess.
Thanks for doing this guys. I've added in the NULL check in to the g-p-m example file: 2006-09-08 Richard Hughes <richard@hughsie.com> * src/gpm-inhibit-test.c: (dbus_inhibit_gpm), (dbus_uninhibit_gpm): Don't treat error like a boolean. Also check for a NULL proxy and warn. From a comment in #344979
Hey Richard, might be nice to add an async example like this one too. Is the example on the GNOME wiki too?
The gnome wiki just links to http://cvs.gnome.org/viewcvs/*checkout*/gnome-power-manager/src/gpm-inhibit-test.c How do you mean an async example? The code is async already, right?
The patch on this bug uses dbus_g_proxy_begin_call etc which asynchronously invokes the method. Might be a helpful example for things like rhythmbox or gnome-vfs that can't or shouldn't use synchronous IO.
Ohh, dbus-call-async, gotcha. Let me add this to the example file as an example (can't promise time, I'm a bit rammed today).
Created attachment 72438 [details] [review] updated just fixing the above nits.
There's a possible problem with patch 72438 : + <key>/schemas/apps/rhythmbox/plugins/power-manager/hidden</key> + <applyto>/apps/rhythmbox/plugins/power-manager/active</applyto> should probably be : + <key>/schemas/apps/rhythmbox/plugins/power-manager/hidden</key> + <applyto>/apps/rhythmbox/plugins/power-manager/hidden</applyto> shouldn't it?
Yes, you're right. Thanks for spotting that.
Looks good to me.
I haven't done any testing, but looks good to me too.
Feel free to commit.
ok, committed.