You are not logged in.

#1 2008-01-24 11:57:21

Allan
Member
From: Brisbane, AU
Registered: 2007-06-09
Posts: 10,839
Website

Inhibit gnome-screensaver

I want to inhibit gnome-screensaver from starting while I run mplayer.   There is a command "gnome-screensaver-command --inhibit" which should work but even with that running I still have gnome-screensaver starting.  I also can't get any dbus based commands/scripts to stop it. 

I am running XFCE.  Does that command work other XFCE users? How about GNOME users?

Offline

#2 2008-01-24 14:46:58

MrWeatherbee
Member
Registered: 2007-08-01
Posts: 277

Re: Inhibit gnome-screensaver

Allan wrote:

I want to inhibit gnome-screensaver from starting while I run mplayer.   There is a command "gnome-screensaver-command --inhibit" which should work but even with that running I still have gnome-screensaver starting.  I also can't get any dbus based commands/scripts to stop it. 

I am running XFCE.  Does that command work other XFCE users? How about GNOME users?

Though I use xscreensaver, I just installed gnome-screensaver to see what was up. I tested your python DBUS script, and it seems to work fine here. The inhibit cookie is being created (I threw in a print statement just to see the value), and it is being observed until the selected video finishes. As soon as the video finishes, mplayer exits and the screensaver kicks in as expected.

I'm not sure why you are getting different results, but you can run this from the command line or in a script as it might be helpful for testing:

dbus-send --session --dest=org.gnome.ScreenSaver --type=method_call --print-reply --reply-timeout=20000 /org/gnome/ScreenSaver org.gnome.ScreenSaver.Inhibit string:"MPlayer" string:"Watching video"

It's pretty much the command-line version of what you have in your python DBUS-object code.

By the way, I only passed the 'file' argument to the script when testing, meaning I did not pass mplayer any other options via the python script. I don't know if that is relevant or not.

The gnome-screensaver command-line worked as well:

gnome-screensaver-command -i -n mplayer -r test

MPlayer used to have a command that simulated activity (−heartbeat−cmd) but it doesn't seem to be available anymore (at least not in the Arch version). Also, if you used xscreensaver, MPlayer's '-stop-xscreensaver' command is available.

Of course other alternatives could include simply killing gnome-screensaver and then restarting it via a script, though that may not be as elegant as using built-in commands or DBUS signals.

Edit:

Tested with gnome + openbox here. I only have XFCE-WM4 installed (not the full XFCE desktop) and I didn't test that yet.

Last edited by MrWeatherbee (2008-01-24 15:06:25)

Offline

#3 2008-01-24 22:48:28

Allan
Member
From: Brisbane, AU
Registered: 2007-06-09
Posts: 10,839
Website

Re: Inhibit gnome-screensaver

Well I just tried both those lines and neither worked here.  I wonder why gnome-screensaver isn't listening to anything I give it...

I may have to resort to being less elegant and just killing it yet!

Offline

#4 2008-03-27 06:08:20

kwidzin
Member
From: Gdansk, Poland
Registered: 2007-02-04
Posts: 26

Re: Inhibit gnome-screensaver

I recompiled MPlayer with attached patch, and now everything is OK.

--- libvo/x11_common.c.debian    2007-02-22 13:50:30.000000000 +0100
+++ libvo/x11_common.c    2007-02-22 13:50:30.000000000 +0100
@@ -77,6 +77,7 @@
 static int dpms_disabled = 0;
 static int timeout_save = 0;
 static int kdescreensaver_was_running = 0;
+static int gnome_screensaver_was_running = 0;
 
 char *mDisplayName = NULL;
 Display *mDisplay = NULL;
@@ -1717,7 +1718,12 @@
             ("dcop kdesktop KScreensaverIface enable true 2>/dev/null >/dev/null");
         kdescreensaver_was_running = 0;
     }
-
+    if (gnome_screensaver_was_running && stop_xscreensaver)
+    {
+        system
+            ("gconftool-2 --type bool --set /apps/gnome-screensaver/idle_activation_enabled true 2>/dev/null >/dev/null");
+        gnome_screensaver_was_running = 0;
+    }
 
 }
 
@@ -1771,6 +1777,17 @@
             system
                 ("dcop kdesktop KScreensaverIface enable false 2>/dev/null >/dev/null");
     }
+    if (stop_xscreensaver && !gnome_screensaver_was_running)
+    {
+        gnome_screensaver_was_running =
+            (system
+             ("gconftool-2 --get /apps/gnome-screensaver/idle_activation_enabled | grep true 2>/dev/null >/dev/null")
+             == 0);
+        if (gnome_screensaver_was_running)
+            system
+                ("gconftool-2 --type bool --set /apps/gnome-screensaver/idle_activation_enabled false 2>/dev/null >/dev/null");
+    }
+
 }
 
 static XErrorHandler old_handler = NULL;

Offline

#5 2008-10-28 11:35:56

jakadinho
Member
From: Kranj, Slovenia
Registered: 2008-10-25
Posts: 32
Website

Re: Inhibit gnome-screensaver

Can you plz tell how did u manage to patch mplayer ? Im new to Arch and i dint relly know how.

Offline

#6 2009-10-08 16:36:12

leniviy
Member
Registered: 2009-05-23
Posts: 165

Re: Inhibit gnome-screensaver

Hi. sorry for necroposting. People sugges a few commands to temporary stop screensaver in GNOME when playing videos. Here they are:

dbus-send --session --dest=org.freedesktop.ScreenSaver --type=method_call /ScreenSaver org.gnome.ScreenSaver.SimulateUserActivity
dbus-send --session --dest=org.gnome.ScreenSaver --type=method_call --print-reply --reply-timeout=20000 /org/gnome/ScreenSaver org.gnome.ScreenSaver.Inhibit string:"MPlayer" string:"Watching video"
gnome-screensaver-command --poke

But with all of them the screensaver is being disabled until I logout/login. In screensaver settings I set the 1 minute timeout, then run one of the above commands and wait 2 mins. The screensaver doesn't start. Why?


Arch 64, xfce4

Offline

Board footer

Powered by FluxBB