! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
dbus screensaver detection starts a screen locker even if one is already running
Status:
RESOLVED: INVALID
Product:
Xfce4-power-manager
Component:
General

Comments

Description ageng 2017-03-26 18:55:42 CEST
Created attachment 7059 
dbus-to-xscreensaver shim for workaround

Symptom
=======
When xfce4-power-manager is started, if xscreensaver is already running and cinnamon's screensaver is installed, cinnamon's screensaver still gets started. (It's fun seeing two screen lockers fight each other if your screen locks before you remember to kill one of them. I haven't figured out whether it's the fault of X, xscreensaver, or cinnamon-screensaver that such fighting just kills my entire session about 10% of the time.)

To reproduce
============
1. Start an xfce session
2. Kill xfce4-power-manager
3. Start xscreensaver
4. (just to see the dbus call) dbus-monitor | grep -A1 StartServiceByName
5. Start xfce4-power-manager

I see lines like the below, followed by cinnamon-screensaver starting. In a more perfect world this StartServiceByName call wouldn't happen since we'd notice xscreensaver was already running.

method call time=1490476307.281437 sender=:1.101 -> destination=org.freedesktop.DBus serial=29 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=StartServiceByName
   string "org.cinnamon.ScreenSaver"

Mechanism
=========
In xfce-screensaver.c:xfce_screensaver_setup, the invocations of screen_saver_proxy_setup to determine the screensaver backend by trial and error are causing calls to org.freedesktop.DBus.StartServiceByName--seemingly without trying to detect if a screensaver is already running.

Workaround(s)
=============
I know next to nothing about DBus so I can't suggest a fix.

On a single-user machine, just uninstall the screen lockers you aren't using.

Otherwise, here's a workaround I just tested ten minutes ago:

Since it tries org.freedesktop.ScreenSaver first, one can create a wrapper to invoke the preferred screen-locker. Something like the following in /usr/share/dbus-1/services/org.freedesktop.ScreenSaver.service:

[D-BUS Service]
Name=org.freedesktop.ScreenSaver
Exec=/usr/local/bin/xscreensaver-dbus-screenlock-freedesktop.py

...where the python script (also attached) is by phDaemon on ubuntuforums, retrieved from https://aur.archlinux.org/packages/xscreensaver-dbus-screenlock/ .

Similar bugs
============
* https://bugzilla.xfce.org/show_bug.cgi?id=3770 was the same bug but for xflock4 and with a different mechanism (ps vs which in shell scripts).
* https://bugzilla.xfce.org/show_bug.cgi?id=10609 is almost the same visible-to-user behavior, but again with a different mechanism. (This was before dbus screen locking (https://bugzilla.xfce.org/show_bug.cgi?id=12603)--it was instead done by shelling out, and gnome-screensaver was the first screen locker probed.)
Comment 1 Ali Abdallah editbugs 2017-11-15 20:44:21 CET
Thanks for the report.

What if xscreensaver checks for other running screensavers? If no one is running, acquires the freedesktop screensaver dbus name, making itself visible to other screensavers? 

Even better, what if you simply install one screensaver on your system? 

Defintely it is not a xfce power manager's bug.

Bug #13459

Reported by:
ageng
Reported on: 2017-03-26
Last modified on: 2017-11-15

People

Assignee:
Ali Abdallah
CC List:
3 users

Version

Attachments

dbus-to-xscreensaver shim for workaround (793 bytes, application/octet-stream)
2017-03-26 18:55 CEST , ageng
no flags

Additional information