GNOME Bugzilla – Bug 571885
inhibit power management (sleep/screensaver) when rendering and previewing
Last modified: 2012-01-02 17:05:26 UTC
When rendering, inhibit gnome-power-manager to prevent the computers from going into sleep/hibernate/whatever automatically When playing, inhibit gnome-screensaver to prevent the screen from turning off/locking.
That would indeed be an awesome feature. We would need a platform/arch/environment independent way of doing that. Something along the lines of pitivi.system.inhibit_standby and pitivi.system.inhibit_screensaver, and move the gnome/kde/win/mac/... specific implementations in there.
I think this is the new documentation for gnome session, since it has been moved out of g-p-m: http://www.gnome.org/~mccann/gnome-session/docs/gnome-session.html#org.gnome.SessionManager.Inhibit
Please review branch git remote add git://github.com/lostcookie/pitivi.git git branch --track system2 lostcookie/system2 and tell me if the basic design is acceptable and where/if things need improving. and once things look like they wont need major changes I will write up some tests :)
Please review branch again, using a different branch because history changed (system3) git remote add git://github.com/lostcookie/pitivi.git git branch --track system2 lostcookie/system3 I added tests that should confirm Session and GnomeSession are working, though I am rather inexperienced in writing tests.
Hi Stephen, thanks for working on this. I had a look at the code, it looks fine. I tried running your branch and it doesn't work here though. I tried setting a breakpoint in GnomeSystem._updatePowerInhibitionCb and it is called when rendering starts, but it doesn't actually inhibit the screen saver for some reason. Can you try to rebase the branch on master (git fetch origin && git rebase origin/master) and check if it works for you?
Created attachment 154351 [details] script to test the state of org.gnome.SessionManager I wrote a script to test the state of org.gnome.SessionManager. you have to press update to get the current state. What should happen at startup: *everything should be unblocked, this can be affected by other applications as well as pitivi when rendering: *logout blocked, suspend blocked *everything else unblocked when playing back video: *session idle blocked *everything else unblocked otherwise: *everthing unblocked
Changing milestone as discussed on #pitivi
I tested the system3 branch today on Ubuntu 10.04, and it works as expected: it inhibits suspend when rendering, and inhibits screen blanking while playing. If the code is allright, then I guess this could be reviewed for merging in master now that we're back into development series.
Some comments: * passing system to the encodingdialog/viewer is unneeded, the Application instance already has the System instance. Remove it from the __init__ and make those classes just use app.system * You're using gtk.gdk.* in system.py but not importing it ? You're currently not passing any icons, but in case you do it should be checked. * For the translatable strings It might be better to be a tiny bit more verbose: ** "Playing timeline" , or if the dialog doesn't show the app "Playing timeline in PiTiVi" ** "Rendering timeline", add "in PiTiVi" if not specified * Using the presence of 'GNOME_DESKTOP_SESSION_ID' in os.environ to detect if you're in a gnome sessions seems a bad idea. I'm getting this on a gnome 2.30.2 system: GNOME_DESKTOP_SESSION_ID=this-is-deprecated * Have you tested the code on non-gnome systems ? * Have you run make check on non-gnome systems ?
I just rebased my old repo onto current git master. I made the fixes suggested but still havn't done checks on non-gnome systems. How many do you think I need to test? Downloading kubuntu-desktop now!
Testing one non-gnome system should be enough. I don't know if it's worth testing a non-xdg linux system (which will most likely be too old and therefore missing virtually all needed pitivi dependencies).
This bug report seems to be stalled mainly on this open question: Stephen, have you had time to test on non-gnome systems since then? The code still seems to be sitting around in https://github.com/lostcookie/pitivi/commits/system3 ... Status update please? :)
I tested it on a KDE system a while back and all was working fine. The issue at the time (discussed on IRC) was that Ubuntu had issues with the DBus service blocking things as intended and I went ahead and looked at it on fedora which was working fine. The locations to block and unblock the power saving changed with Brandon's rendering dialog improvements. I created a new branch rebased on master, but removed all the code that did blocking/unblocking. On a personal note I haven't done a lot of programming recently due to some personal issues. So when this gets finished is anyones guess.
Hey Stephen, I tried rebasing your branch again on https://github.com/nekohayo/pitivi/commits/power-inhibit (I also used the rebase to slightly edit the last two commits, to replace the strings "Playing Med" (sic) and "Rendering Media" by "Currently playing media" and "Currently rendering media") Problem is that if I load a simple project it works, but as soon as I try loading a complex projects with ~20-40 clips in the timeline (tried with two different projects), it segfaults when it reaches the state where it needs to populate the timeline. Maybe I rebased it incorrectly? Could you have a look? Some questions: - In encodingdialog.py: doesn't app.app.system sound a bit strange? - In runtests.py it seems you add some sort of device for it to ignore certain tests... but this thing doesn't seem to be taken into account anywhere in the code. Or maybe I did a mistake while rebasing? - How do you run the test? Other than that, the code seems quite neat, I still have to see whether it actually works (stuck with my segfault problem above). If this thing works as intended on Fedora with no visible regressions, then I'll merge it... perfect is the enemy of good.
Rebased it again on the ges port today, with minor fixes. Tested, works fine. Test suite runs OK.
commit 713409c6f8f420d9e10d05c365534a3a3a583137 Author: Thibault Saunier <thibault.saunier@collabora.com> Date: Mon Jan 2 13:55:06 2012 -0300 tests: Run and fix test_system_* commit 473cb0448f9b6bd6b318dc5e84e4c11b95c3df68 Author: Jean-François Fortin Tam <nekohayo@gmail.com> Date: Mon Jan 2 11:33:33 2012 -0500 Properly connect to the pipeline state when rendering to inhibit sleep commit 21c0d74a8b82dbbab8090c1613274b0460c1bf7c Author: Stephen Griffiths <stevie.craig.griffiths@gmail.com> Date: Thu Feb 17 17:19:12 2011 +1100 pitivi/ui/encodingdialog.py: inhibit logging out, inhibit suspend/shutdown etc. when rendering commit a35c45c94e78c8edc41b3d924f56f0bff5c4e1a8 Author: Stephen Griffiths <stevie.craig.griffiths@gmail.com> Date: Thu Feb 17 15:52:11 2011 +1100 pitivi/ui/viewer.py: inhibit screensaver whilst previewing videos. commit 89d42b041797351230383fbbc00aedb25f9fcf5a Author: Stephen Griffiths <stevie.craig.griffiths@gmail.com> Date: Thu Feb 17 15:20:57 2011 +1100 pitivi/application.py: get a system when initialising commit 823f174f7eefef34379acd786297446d8c92b0f6 Author: Jean-François Fortin Tam <nekohayo@gmail.com> Date: Sun Jan 1 20:11:43 2012 -0500 tests/test_system.py: test that adding and removing keys occurs properly tests/test_system_gnome.py: test powersaving works on GNOME commit f038732ba76beddda62d7b19c962e6b74ef1bab6 Author: Stephen Griffiths <scgmk5@gmail.com> Date: Wed Feb 10 23:07:06 2010 +1100 pitivi/Makefile.am: add system.py commit dc3cff1d958776c435f4ae4e87534f34809fe85c Author: Stephen Griffiths <scgmk5@gmail.com> Date: Wed Feb 10 23:04:33 2010 +1100 pitivi/system.py: implement getSystem(), gets the best available *System commit 5342cf323764893f52d7302b1e895d0155928836 Author: Stephen Griffiths <scgmk5@gmail.com> Date: Wed Feb 10 23:00:55 2010 +1100 pitivi/system.py: implement GnomeSystem, adds power inhibition for GNOME commit fb0e6917c7c4aaee9520a5883372758ee825a70c Author: Stephen Griffiths <scgmk5@gmail.com> Date: Wed Feb 10 22:57:59 2010 +1100 pitivi/system.py: implement FreedesktopOrgSystem, a base class for desktops implementing fd.o specs commit c3ade21a6e144110f43a99063f31a38a9f52d2c8 Author: Stephen Griffiths <scgmk5@gmail.com> Date: Wed Feb 10 22:52:39 2010 +1100 pitivi/system.py: implement System, a base class for other systems