! 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 !
Cannot start xfce4-screensaver via systemd service file.
Status:
RESOLVED: INVALID
Product:
Xfce4-screensaver
Component:
General

Comments

Description ricardobirf 2020-01-25 22:03:53 CET
I built xfce4-screensaver with systemd support 

```
./autogen.sh --prefix=/usr --sysconfdir=/etc --with-systemd
make && sudo make install
```

and tried starting it with the following service file 'xfce4-screensaver.service', which I created in '/etc/systemd/system/':

```
[Unit]
Description=Xfce Screensaver daemon.
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/xfce4-screensaver --debug
ExecStop=/usr/bin/xfce4-screensaver-command --exit

[Install]
WantedBy=multi-user.target
```

Reloading the daemons and trying to start the service results in an error

```
sudo systemctl daemon-reload
sudo systemctl start xfce4-screensaver
sudo journalctl -e -u xfce4-screensaver
...
Jan 25 21:51:38 laptop-linux systemd[1]: Started Xfce Screensaver daemon..
Jan 25 21:51:38 laptop-linux xfce4-screensaver[475]: Unable to init server: Verbindung ist gescheitert: Verbindungsaufbau abgelehnt
Jan 25 21:51:38 laptop-linux xfce4-screensav[475]: Anzeige kann nicht geöffnet werden: 
Jan 25 21:51:38 laptop-linux systemd[1]: xfce4-screensaver.service: Main process exited, code=exited, status=1/FAILURE
Jan 25 21:51:38 laptop-linux systemd[1]: xfce4-screensaver.service: Failed with result 'exit-code'.
```
How do I get rid of the "Unable to init server: could not connect: connection refused" / "Cannot open display" error?

Calling 'xfce4-screensaver' and 'xfce4-screensaver-command' from the terminal works as expected.
Comment 1 Theo Linkspfeifer editbugs 2020-01-27 13:40:41 CET
I assume that "systemd" refers to logind support, see:
https://www.freedesktop.org/wiki/Software/systemd/logind/

The problems with your xfce4-screensaver service (requiring root, no display) can be solved by writing a user unit file instead. More information here:
https://wiki.archlinux.org/index.php/Systemd/User
Comment 2 ricardobirf 2020-03-08 15:29:56 CET
Probably?!

I found out that I did not even have to create any service file for systemd/logind, since xfce4-screensaver seems to be automagically started on startup..
I did not notice right away, since by force of habit I was trying to control it with `sudo`, which did not work because it is running under my username:

``` 
sudo xfce4-screensaver-command -q
** Message: 15:14:08.142: Screensaver is not running! Start xfce4-screensaver first
```

Wheras without `sudo`:

``` 
xfce4-screensaver-command -q
Der Bildschirmschoner ist inaktiv
Der Bildschirmschoner ist nicht blockiert
``` 

it works just fine and, as mentioned, is running without me adding any start script or entry anywhere.

Nevertheless, I tried stopping xfce4-screensaver (`xfce4-screensaver-command --exit`) and starting it with the following user-specific systemd/logind service file:

```
[Unit]
Description=Xfce Screensaver daemon.
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/xfce4-screensaver --debug
ExecStop=/usr/bin/xfce4-screensaver-command --exit

[Install]
WantedBy=default.target
```

and controlling it with the respective commands:

```
systemctl --user enable xfce4-screensaver-user
systemctl --user start xfce4-screensaver-user 
# Check if it worked!
systemctl --user status xfce4-screensaver-user 
# Potentially stop it manually.
systemctl --user stop xfce4-screensaver-user 
```

, which worked just fine.
Comment 3 ricardobirf 2020-03-08 15:31:09 CET
I cannot find a way to close this bug report, could anyone please do this for me?

Thanks!
Comment 4 Theo Linkspfeifer editbugs 2020-03-08 20:38:20 CET
Done.

Bug #16405

Reported by:
ricardobirf
Reported on: 2020-01-25
Last modified on: 2020-03-08

People

Assignee:
Sean Davis
CC List:
0 users

Version

Attachments

Additional information