DBUS: how about org.freedesktop.ScreenSaver instead of gnome?

1,211 views
Skip to first unread message

Hans Ecke

unread,
Jun 8, 2012, 1:25:20 PM6/8/12
to gnome-mplayer
Hi there-

In looking through gnome-mplayer's sources, I see that you are using one
of three methods to disable and enable the screensaver:

* XScreenSaverSuspend()
* dbus calls to org.gnome.ScreenSaver
* dbus calls to org.gnome.SessionManager

But there is no support for other desktop environments like XFCE or KDE.
When I looked into the issue I saw that there is a generic dbus API
called org.freedesktop.ScreenSaver. All desktop environments should
implement it. For instance, within gnome, if you call
org.freedesktop.ScreenSaver/Inhibit, it would be forwarded to either
org.gnome.ScreenSaver/Inhibit or org.gnome.SessionManager/Inhibit,
depending on your gnome version. In KDE, the same call will be forwarded
to a KDE-specific service. Either way, it will do the right thing, even
outside of gnome.

http://lists.freedesktop.org/archives/xdg/2007-March/009187.html
http://foss-boss.blogspot.com/2008/11/ride-d-bus-control-your-linux-desktop.html

Could somebody check this in a gnome session? I can see the correct
results if I do this on the command line:

qdbus org.freedesktop.ScreenSaver /ScreenSaver

But I don't know if the "qdbus" tool is installed if you are running
gnome...

Cheers

Hans

--
Hans Ecke Department of Physics
he...@mines.edu Colorado School of Mines
(USA) 303-273-3850 Golden, Colorado

If you lend someone $20, and never see that person again; it was probably
worth it.

Kevin DeKorte

unread,
Jun 8, 2012, 1:45:21 PM6/8/12
to gnome-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06/08/2012 11:25 AM, Hans Ecke wrote:
> Hi there-
>
> In looking through gnome-mplayer's sources, I see that you are
> using one of three methods to disable and enable the screensaver:
>
> * XScreenSaverSuspend() * dbus calls to org.gnome.ScreenSaver *
> dbus calls to org.gnome.SessionManager
>
> But there is no support for other desktop environments like XFCE or
> KDE. When I looked into the issue I saw that there is a generic
> dbus API called org.freedesktop.ScreenSaver. All desktop
> environments should implement it. For instance, within gnome, if
> you call org.freedesktop.ScreenSaver/Inhibit, it would be forwarded
> to either org.gnome.ScreenSaver/Inhibit or
> org.gnome.SessionManager/Inhibit, depending on your gnome version.
> In KDE, the same call will be forwarded to a KDE-specific service.
> Either way, it will do the right thing, even outside of gnome.
>
> http://lists.freedesktop.org/archives/xdg/2007-March/009187.html
> http://foss-boss.blogspot.com/2008/11/ride-d-bus-control-your-linux-desktop.html
>
> Could somebody check this in a gnome session? I can see the
> correct results if I do this on the command line:
>
> qdbus org.freedesktop.ScreenSaver /ScreenSaver
>
> But I don't know if the "qdbus" tool is installed if you are
> running gnome...
>
> Cheers
>
> Hans
>

Hans,

I was not aware of that specification, thanks for bringing to to my
attention. I will work on it.

Kevin



- --
Get my public GnuPG key from
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7D0BD5D1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEUEARECAAYFAk/SOi4ACgkQ6w2kMH0L1dG99wCePvtZPunBM72kfTyN9M7xYqfS
bxwAliohM/LUF3U8w+ngPSeQo62Al44=
=Rf0Y
-----END PGP SIGNATURE-----

Hans Ecke

unread,
Jun 8, 2012, 4:48:00 PM6/8/12
to gnome-...@googlegroups.com
> Hans,
>
> I was not aware of that specification, thanks for bringing to to my
> attention. I will work on it.
>
> Kevin

Hi Kevin-

I researched this a bit further, and it seems that Gnome does not yet
implement that spec. It seems that for the moment screensaver
en/disabling is desktop environment specific. Or that you could hope
that the desktop does the right thing with those XScreenSaverSuspend()
calls.

I think gnome-mplayer should correctly disable screensavers even when
not run under Gnome. Would you agree?

Possibilities:

* implement org.freedesktop.ScreeenSaver as well, so non-gnome desktops
can do the right thing

* use the standard xdg-screensaver script. It is part of freedesktop's
xdg-utils package. It is bash and if you review the code you see that it
tries to determine the current desktop and use whatever method seems
appropriate.

I think the code inside gnome-mplayer which handles the screensaver
should try to determine the correct method itself. How about something
like this:

You have a bunch of functions, each of which tries one method to toggle
the screensaver. So you have

bool switch_screensaver_gnome_screensaver(gboolean enabled);
bool switch_screensaver_gnome_sessionmanager(gboolean enabled);
bool switch_screensaver_freedesktop_screensaver(gboolean enabled);
bool switch_screensaver_xdg_screensaver(gboolean enabled);

The boolean return value tells you if the function thinks it managed to
actually do something. For instance, if the dbus call succeeded, or if
it could find the xdg-screensaver executable. Then the main switch
function would look like so:

bool switch_screensaver(gboolean enabled) {
if(switch_screensaver_gnome_screensaver(enabled)) {
return true;
}
if(switch_screensaver_gnome_sessionmanager(enabled)) {
return true;
}
if(switch_screensaver_freedesktop_screensaver(enabled)) {
return true;
}
if(switch_screensaver_xdg_screensaver(enabled)) {
return true;
}
return false;
}

You could even try and fit the XScreenSaverSuspend() call into this
chain as a method of last resort. But I don't know the history of this
code in gnome-mplayer. What prompted you to make it a config option?

Cheers

Hans

Kevin DeKorte

unread,
Jun 9, 2012, 9:31:49 AM6/9/12
to gnome-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hans,

The XScrnSaver code was added specifically for XFCD/LXDE because they
used/use XscreenSaver for locking the display. In fact that was the
original use case for adding support in.

Of course gnome has to do its own thing, and the reason I have two
ways of controlling gnome is that they changed the method between
releases. It would have been nice if they would have met the
freedesktop standard, or at least supported it, but apparently they don't.

So the next step I guess would be to query the interfaces and then try
to determine which ones work and then fall back to XScrnSaver if none
of them work.

Kevin


On 06/08/2012 11:25 AM, Hans Ecke wrote:
> Hi there-
>
> In looking through gnome-mplayer's sources, I see that you are
> using one of three methods to disable and enable the screensaver:
>
> * XScreenSaverSuspend() * dbus calls to org.gnome.ScreenSaver *
> dbus calls to org.gnome.SessionManager
>
> But there is no support for other desktop environments like XFCE or
> KDE. When I looked into the issue I saw that there is a generic
> dbus API called org.freedesktop.ScreenSaver. All desktop
> environments should implement it. For instance, within gnome, if
> you call org.freedesktop.ScreenSaver/Inhibit, it would be forwarded
> to either org.gnome.ScreenSaver/Inhibit or
> org.gnome.SessionManager/Inhibit, depending on your gnome version.
> In KDE, the same call will be forwarded to a KDE-specific service.
> Either way, it will do the right thing, even outside of gnome.
>
> http://lists.freedesktop.org/archives/xdg/2007-March/009187.html
> http://foss-boss.blogspot.com/2008/11/ride-d-bus-control-your-linux-desktop.html
>
> Could somebody check this in a gnome session? I can see the
> correct results if I do this on the command line:
>
> qdbus org.freedesktop.ScreenSaver /ScreenSaver
>
> But I don't know if the "qdbus" tool is installed if you are
> running gnome...
>
> Cheers
>
> Hans
>


- --
Get my public GnuPG key from
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7D0BD5D1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/TUEUACgkQ6w2kMH0L1dEiQQCfT15tUcAGBied/JtSFBDB4EyT
YrkAoI9RtiELUUKtstNV9WmhZsGtbn5B
=LVbL
-----END PGP SIGNATURE-----

Hans Ecke

unread,
Jun 9, 2012, 1:00:21 PM6/9/12
to gnome-...@googlegroups.com
Hi Kevin-

> So the next step I guess would be to query the interfaces and then try
> to determine which ones work and then fall back to XScrnSaver if none
> of them work.

Want me to send you a patch?

Have a nice weekend

Hans



Kevin DeKorte

unread,
Jun 9, 2012, 1:30:15 PM6/9/12
to gnome-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sure!

Kevin

- --
Get my public GnuPG key from
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7D0BD5D1
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/TiCcACgkQ6w2kMH0L1dHG1ACdHNQRAPOYqd8DFtj8sgmLeup7
AwAAnAo/Y9DuOo2wLqMyUvyQPQCow570
=8JSp
-----END PGP SIGNATURE-----

Hans Ecke

unread,
Jun 9, 2012, 2:04:39 PM6/9/12
to gnome-...@googlegroups.com
>>> So the next step I guess would be to query the interfaces and
>>> then try to determine which ones work and then fall back to
>>> XScrnSaver if none of them work.
>>
>> Want me to send you a patch?
>
> Sure!
>
> Kevin

I'll probably get to it sometime next week.

Hans

Reply all
Reply to author
Forward
0 new messages