ARR8 / surface-tools

Tools for using the Microsoft Surface with Linux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

service unit with systemd doesn't work

tillhanke opened this issue · comments

I tried to create a systemd service for autorotate and penmon. But if I start the services they throw errors and don't work properly.
Anyone able to help me here?
My service file for autorotate is:

[Unit]
Description=screen rotate

[Service]
type=simple
ExecStart=python /home/till/Downloads/surface-tools-master/autorotate/autorotate

and systemctl status autorotate shows just:

autorotate.service - screen rotate
   Loaded: loaded (/etc/systemd/system/autorotate.service; static; vendor preset: disabled)
   Active: active (running) since Fri 2019-05-24 11:55:13 CEST; 4s ago
 Main PID: 18622 (python)
    Tasks: 1 (limit: 4915)
   Memory: 13.7M
   CGroup: /system.slice/autorotate.service
           └─18622 /usr/bin/python /home/till/Downloads/surface-tools-master/autorotate/autorotate

Mai 24 11:55:13 surface-manjaro systemd[1]: Started screen rotate.
Mai 24 11:55:14 surface-manjaro python[18622]: Unable to init server: Could not connect: Connection refused
Mai 24 11:55:14 surface-manjaro python[18622]: Unable to init server: Could not connect: Connection refused
Mai 24 11:55:14 surface-manjaro python[18622]: Can't open display
Mai 24 11:55:14 surface-manjaro python[18622]: Failed to open Display .
commented

Hi there, do you still need help for this? Autorotate is downstream of X11 and thus inappropriate for systemd, which also handles services on the tty, and thus doesn't make use of the display server even if it is available. What would work is an autostart mechanism exclusive to Xorg, such as dropping or symlinking a .desktop file into $XDG_CONFIG_HOME/autostart for one user or /etc/xdg/autostart for the whole system, or, if you use a DE, whatever autostart mechanism that uses. Or a line in an Xinitrc file, whatever Wayland does, etc.

If you are looking for a script that will also allow rotation while in tty, this is not it. Although it could possibly be written to work that way, rotation is presumably not very useful for the tty because requires a physical keyboard and is not touchscreen-friendly.