mate-desktop / mate-screensaver

MATE screen saver and locker
https://mate-desktop.org
GNU General Public License v2.0
48 stars 40 forks source link

MATE ScreenScreensaver should implement "XDG" Idle Inhibition Service specification #57

Open ntninja opened 10 years ago

ntninja commented 10 years ago

GNOME and KDE already implement it and at least VLC and Firefox (33+) make use of it. It's not an "offical" Freedesktop specification but it has become a "defacto-standard". Link: http://people.freedesktop.org/~hadess/idle-inhibition-spec/

Things to do:

  1. Claim DBus bus name org.freedesktop.ScreenSaver additionally to org.mate.ScreenSaver
  2. Expose the MATE ScreenSaver interface (org.mate.ScreenSaver) as org.freedesktop.ScreenSaver on the object paths /ScreenSaver and /org/freedesktop/ScreenSaver
  3. That's it! MATE ScreenSaver already implements the required methods: Inhibit and UnInhibit correctly!

The reason why you have add both the /ScreenSaver and /org/freedesktop/ScreenSaver object paths is because KDE orginally only added /ScreenSaver while /org/freedesktop/ScreenSaver fits into the official scheme. The spec fails to mention object paths entirly, but GNOME adds both paths so I guess that is what should be used... Also GNOME exports all for its ScreenSaver methods via org.freedesktop.ScreenSaver althrough the spec only says you have to export the Inhibit and UnInhibit methods so I guess that's how it should be done...

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/4363731-mate-screenscreensaver-should-implement-xdg-idle-inhibition-service-specification?utm_campaign=plugin&utm_content=tracker%2F1635706&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1635706&utm_medium=issues&utm_source=github).
ntninja commented 10 years ago

In the meantime, here is a polyfill that implements the required methods and forwards them to MATE ScreenSaver: https://gist.github.com/alexander255/9b991816418e4e60ee7c

MotoHoss commented 9 years ago

Please see also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=768326 possibly mate-session-manager mate-power-manager Thanks!

shirishag75 commented 9 years ago

Would this be fixable anytime soonish ?

monsta commented 9 years ago

Looks related: https://bugs.launchpad.net/bugs/1019878

flexiondotorg commented 9 years ago

Looks related: https://bugs.launchpad.net/ubuntu-mate/+bug/1403503

wshanks commented 9 years ago

Since @monsta linked to an issue with VLC above, I want to add that VLC successfully blocks the screensaver for me once I have selected the "Disable screensaver" setting in the Video section of the VLC preferences. I am using VLC 2.2.0 and Mate 1.8.2 on Arch. This may be relevant to someone trying to test this bug. VLC might not be a good choice for testing because I still see this bug when using other video players like Firefox with H264 or using caffeine (here is the equivalent bug for caffeine: https://bugs.launchpad.net/caffeine/+bug/1026411).

I tried the script @alexander255 provided. It ran without error but did not inhibit the screensaver in my testing. Anyone know how much work it would take to fix this issue? I'd like to help but know nothing about Mate/dbus development.

ntninja commented 9 years ago

@willsALMANJ

That script will not actually become operational before it wasn't able to connect to MATE screensaver over dbus; if you don't get any feedback that means that is DOES NOT work! I've updated the script slightly to give a bit more feedback about what is going on. Please also try running mate-screensaver-command -a to make sure MATE screensaver is actually running. Additionally you might want to install d-feet and check which application (if any) has acquired the name org.freedesktop.ScreenSaver on the session bus (since that is what applications will connect to if they want to inhibit the screensaver).

Workload estimate: As mentioned in my opening post you'd just have to expose MATE screensaver's org.mate.ScreenSaver interface on org.freedesktop.ScreenSaver with the /ScreenSaver and /org/freedesktop/ScreenSaver object paths to enable native support for this feature. Most of your changes would happen in this file. MATE ScreenSaver still uses the dbus-glib API so you can't just adopt the current GNOME source code (that uses the more modern GDBus API). You don't need to know a lot about any MATE internals, just take the current source file as a starting point and keep the calls into MATE screensaver's lower layers the way they are right now. You do need some knowledge of C/GObject, DBus in general and dbus-glib specifcally through. The first thing to do would definitely to write an example dbus service that serves the org.freedesktop.ScreenSaver interface using the dbus-glib API (basically the C equivalent of what my Python script does), then integrate that into the existing source code. Let me know if you have any questions :-)

shirishag75 commented 9 years ago

Umm.. @willsALMANJ I have also checked disabled screensaver from long time back but still the screensaver does not get blocked.

vlc-all-preferences-video

@alexander255 how to know using d-feet. The man page is just 2 lines with no example or anything so it's not known. Could you guide so we may know if any application has acquired org.freedesktop.ScreenSaver

ntninja commented 9 years ago

@shirishag75 Sure, follow this guide:

  1. Open d-feet
  2. Select the Session Bus tab (1)
  3. Enter org.freedesktop.ScreenSaver (or whatever you're looking for) into the text field next to Filter: (2)
  4. The list below the filter text box should shrink to one entry if any application has acquired that bus name or should be become empty if no application uses it
  5. If you found an entry you can click on it and it will show you all of the interfaces, object, properties, methods and signal that are provided by the application. Using my screenshot you can verify if you have a screensaver that implements all the "usual" methods by expanding /org/freedesktop/ScreenSaver -> Interfaces -> org.freedesktop.ScreenSaver -> Methods and comparing the entries. (3)

snapshot1

Hope I could help! :-)

wshanks commented 9 years ago

@alexander255 Okay, your script does work for me. I got feedback from it (and checked that it did block the screensaver) for both VLC and Firefox. I'm not sure why it didn't work before. I thought it might be that I needed to have the script running before opening the VLC or Firefox window, but now I can restart the script with Firefox running and then maximize a video and it still works. It didn't work with Google Chrome though.

I will try to review the links you provided and see what I can learn about dbus and MATE. If anyone wants to try this, don't let me discourage you as it will probably be a slow process for me. In the mean time, I found I could all of the functionality I needed from the lightson+.sh script at https://github.com/devkral/lightsonplus (I had to tweak a few lines for it to recognize Chrome properly) and from alexander's script (other than Chrome).

@shirishag75 Yes, that is the setting that I checked in VLC. It works for me with the versions of VLC and MATE that I listed. I didn't do anything else to make it work. With that setting, the screensaver never activates for me when VLC is playing a video (VLC window does not need to fullscreen or even visible). If you use the same versions of the programs and it doesn't work, then I'm not sure what is going on. I see this behavior on Arch Linux. Perhaps the Arch packages use different build options from what you are using.

shirishag75 commented 9 years ago

Hi all, These are the build options that the Debian people used while compiling as seen from vlc -vvvv (don't think anything else would give that) :-

[00000000019c5148] core libvlc debug: configured with ./configure  '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--localstatedir=/var' '--libdir=${prefix}/lib/x86_64-linux-gnu' '--libexecdir=${prefix}/lib/x86_64-linux-gnu' '--disable-dependency-tracking' '--build=x86_64-linux-gnu' 'CPPFLAGS=-D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-z,relro' '--config-cache' '--disable-maintainer-mode' '--disable-silent-rules' '--disable-update-check' '--enable-fast-install' '--prefix=/usr' '--docdir=/usr/share/doc/vlc-nox' '--libdir=/usr/lib' '--sysconfdir=/etc' '--with-binary-version=1' '--enable-a52' '--enable-aa' '--enable-bluray' '--enable-bonjour' '--enable-caca' '--enable-chromaprint' '--enable-dbus' '--enable-dca' '--enable-directfb' '--enable-dvbpsi' '--enable-dvdnav' '--enable-faad' '--enable-flac' '--enable-fluidsynth' '--enable-freerdp' '--enable-freetype' '--enable-fribidi' '--enable-gles1' '--enable-gles2' '--enable-gnutls' '--enable-jack' '--enable-kate' '--enable-libass' '--enable-libmpeg2' '--enable-libxml2' '--enable-lirc' '--enable-live555' '--enable-mad' '--enable-mkv' '--enable-mod' '--enable-mpc' '--enable-mtp' '--enable-mux_ogg' '--enable-ncurses' '--enable-notify' '--enable-ogg' '--enable-opus' '--enable-pulse' '--enable-qt' '--enable-realrtsp' '--enable-samplerate' '--enable-schroedinger' '--enable-sdl' '--enable-sftp' '--enable-shine' '--enable-shout' '--enable-skins2' '--enable-speex' '--enable-svg' '--enable-taglib' '--enable-theora' '--enable-twolame' '--enable-upnp' '--enable-vcdx' '--enable-vdpau' '--enable-vnc' '--enable-vorbis' '--enable-x264' '--enable-zvbi' '--with-kde-solid=/usr/share/kde4/apps/solid/actions/' '--disable-decklink' '--disable-dxva2' '--disable-fdkaac' '--disable-gnomevfs' '--disable-goom' '--disable-libtar' '--disable-mfx' '--disable-opencv' '--disable-projectm' '--disable-sndio' '--disable-svgdec' '--disable-telx' '--disable-vpx' '--disable-vsxu' '--disable-wasapi' '--enable-alsa' '--enable-atmo' '--enable-dc1394' '--enable-dv1394' '--enable-linsys' '--enable-omxil' '--enable-udev' '--enable-v4l2' '--enable-libva' '--enable-vcd' '--enable-smbclient' '--disable-oss' '--enable-crystalhd' '--enable-mmx' '--enable-sse' '--disable-neon' '--disable-altivec' 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security' 'CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security' 'build_alias=x86_64-linux-gnu' 'OBJCFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security'

Sorry for the long output but that's how it is.

wshanks commented 9 years ago

@shirishag75 The discussion of your problem with VLC should probably be taken to a different place since it is not related to changing MATE ScreenSaver to follow the freedesktop standard for DBus registration. That said, you still haven't specified what version of VLC you are using. You reference Debian which usually maintains quite old packages unless you are using the unstable version. I'm not sure how old the versions of VLC are in Debian release/testing/unstable, but explicit MATE support was added to VLC on May 27, 2013 here:

https://git.videolan.org/?p=vlc.git;a=commitdiff;h=0b1ef649c51148cc7bd8ac2573be33b6c3d26592

I would guess this code first appeared in a stable release of VLC in version 2.1.0.

shirishag75 commented 9 years ago

I thought I had already shared that, this is the version I have :-

[$] vlc --version                                                                                                                   
VLC media player 2.2.0-rc2 Weatherwax (revision 2.2.0-rc1-118-g22fda39)
VLC version 2.2.0 Weatherwax (2.2.0-0-g1349ef2)
Compiled by skipper on deep-thought (Apr  6 2015 19:30:31)
Compiler: gcc version 4.9.2 (Debian 4.9.2-10)
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute it under the terms of the GNU General Public License;
see the file named COPYING for details.
Written by the VideoLAN team; see the AUTHORS file.
monsta commented 9 years ago

Ok, the situation with VLC is clear, modern versions have MATE support. I guess we still need to add org.freedesktop.* stuff and maybe also org.gnome.* stuff for other apps.

monsta commented 9 years ago

@alexander255: are you sure it should be done here and not in mate-session-manager? VLC commit posted above references only org.mate.SessionManager.

ntninja commented 9 years ago

@monsta I've reviewed the source code a bit and found that MATE screensaver basically just proxies MATE session's inhibitors (but does remember locally which programs currently hold a lock as well): https://github.com/mate-desktop/mate-screensaver/blob/edb89a74aa0440cd0f59bddf9205d50d91634e2d/src/gs-listener-dbus.c#L786

Also MATE screensaver then uses MATE session to determine when to consider the user session idle/start the screen lock timer: https://github.com/mate-desktop/mate-screensaver/blob/master/src/gs-watcher-x11.c#L436

Some observations:

  1. It makes no difference (for screen timeout), whether a client uses org.mate.SessionManager.Inhibit or org.mate.ScreenSaver.Inhibit.
  2. When using org.mate.SessionManager.Inhibit the lock will not be shown by org.mate.ScreenSaver.GetInhibitors (as MATE ScreenSaver will not know about it).
  3. The org.mate.ScreenSaver.Inhibit method is identical (in terms of parameters) to the org.freedesktop.ScreenSaver.Inhibit method that we are trying to implement. The org.mate.ScessionManager.Inhibit method is made for a more generic use-case.

While it's your call which daemon you choose to "burden" with this task, I'd still go for MATE ScreenSaver, since

monsta commented 9 years ago

@infirit: should we add this to roadmap for 1.12?

infirit commented 9 years ago

We can add it to the roadmap, not sure if 1.12 is realistic but why not.

I do like to stay as close to gnome so this has to be in settings-daemon as a plugin. This allows us to easily pickup code/fixes from there in the future.

shirishag75 commented 7 years ago

ping....any update on this ?

monsta commented 7 years ago

All apps using org.mate.SessionManager had been switched to org.gnome.SessionManager in 1.12. No work on Freedesktop interface done yet. Pull requests are welcome...

luciomoreira commented 7 years ago

I found this solution: I installed gnome-session, login to gnome, logout, and login to mate again, then mate uses gnome inhibitor

shirishag75 commented 7 years ago

@luciomoreira that is not really a solution but a hack but a terrible one at that. The whole idea of MATE is a low-cost, low-memory desktop environment. If I or anyone for that matter could use GNOME comfortably (meaning high memory and CPU usage) than why would anybody use MATE.

A part of the reason is also that it looks / shares GNOME 2 like-look which old-timers like.

I do hope that 1.20.0 does use this. For now I have made an alias which tells me that the specific function inhibit in mpv will go away soonish and will have to rely on MATE for inhibition support.

[$] alias mpv                                                                                                                      
mpv=$'mate-session-inhibit --inhibit\n/usr/bin/mpv'

No programmer hence will stop here.

yetist commented 5 years ago

I think mate-screensaver should implement the freedesktop screensaver api. Although it's only a draft, it's the fact standard, both gnome and KDE implement it, and many application call this org.freedesktop.screensaver dbus api to lock/unlock/inhibit/uninhibit screen lock.

oz123 commented 6 months ago

@ntninja the gist is no longer available. Bountysource is also not available. Anyone here willing to collaborate on this?

oz123 commented 4 months ago

Looking at this issue for quite a while, I think mate should just remove org.mate.ScreenSaver in favor of org.freedesktop.ScreenSaver in the places it's found.

I understand too little how gdbus work to do it myself.

Some interesting discussion found here:

https://bugzilla.mozilla.org/show_bug.cgi?id=1168090

Especially interesting are the comments from xfce4 developers.

If you want to see how firefox inhibits the screensaver:

https://hg.mozilla.org/mozilla-central/file/tip/widget/gtk/WakeLockListener.cpp

oz123 commented 4 months ago

It turns out that the fix is very easy:

https://github.com/mate-desktop/mate-screensaver/compare/master...oz123:mate-screensaver:master

The hardest part was to compile the software and figure out that I need to install everything in the right path. That is, running ./src/mate-screensaver does not really work.

image