he-la / perspektiv

A daemon for creating popups when you change monitor brightness, volume, etc.
GNU General Public License v3.0
28 stars 1 forks source link

Cannot run from systemd service #3

Closed MarcelRobitaille closed 5 years ago

MarcelRobitaille commented 5 years ago

I am trying to create a PKGBUILD for this project. I have everything working except the systemd service.

Here is my perspektiv.service (installed to /usr/lib/systemd/system/):

[Unit]
Description=perspektiv daemon for graphically reporting system events

[Service]
Type=simple
Environment="RUST_BACKTRACE=1"
ExecStart=/usr/bin/env perspektiv
User=1000
Group=1000

[Install]
WantedBy=default.target

When I try to run this service, I get:

Sep 14 11:14:40 Zeus systemd[1]: Started perspektiv daemon for graphically reporting system events.
Sep 14 11:14:40 Zeus env[27976]: Unable to init server: Could not connect: Connection refused
Sep 14 11:14:40 Zeus env[27976]: thread 'main' panicked at 'Failed to initialise GTK.: BoolError("Failed to initialize GTK")', libcore/result.rs:945:5
Sep 14 11:14:40 Zeus env[27976]: stack backtrace:
Sep 14 11:14:40 Zeus env[27976]:    0: <unknown>
Sep 14 11:14:40 Zeus env[27976]:    1: <unknown>
Sep 14 11:14:40 Zeus env[27976]:    2: <unknown>
Sep 14 11:14:40 Zeus env[27976]:    3: <unknown>
Sep 14 11:14:40 Zeus env[27976]:    4: <unknown>
Sep 14 11:14:40 Zeus env[27976]:    5: <unknown>
Sep 14 11:14:40 Zeus env[27976]:    6: <unknown>
Sep 14 11:14:40 Zeus env[279

Any thoughts?

he-la commented 5 years ago

Look's like the systemd unit is starting before the xorg socket is available. To be honest, I didn't check if the unit file worked before comitting, so this is entirely my mistake.

I'm not quite sure how this issue would be best solved. From my understanding, waiting for xorg to be available depends on the display manager being used, so you'd have to detect the display manager in the PKGBUILD and go from there.

I'll see if I can come up with something more practical than that.

he-la commented 5 years ago

I think there is no straightforward way to resolve this issue. If you know the name of the display in which the GUI session runs, you can add Environment="DISPLAY=<name>" to the service section of the unit file, e.g. Environment="DISPLAY=:0". But that's not a portable solution, so I would not recommend it for your PKDBUILD.

Instead, I would leave it up to the user to set up his display manager to start perspektiv. This could be done either by starting a virtual target with the proper DISPLAY variable set, or by starting perspektiv directly.

In your PKDBUILD, I would advise you to simply print a message informing the user that he must configure his system to launch perspektiv.

To avoid confusion, I will remove the systemd unit file from the repository.