0

I have written a sample test service and it looks as below,

 [Unit]
 Description=Test service

 [Service]
 Type=dbus
 BusName=test.sample
 Restart=on-failure
 ExecStart=/usr/sbin/testbin -n
 StandardOutput=null

 [Install]
 WantedBy=multi-user.target

Now I want this service(or unit file) to be started after the xorg.service so I added

After=xorg.service
Requires=xorg.service

to the unit section of my service file and rebooted the system.But it is not having an effect on my service file.So my goal here is to bring this service up after the user session(I mean after X comes up).Please let me know what am I missing here or is there any other alternative approach to delay it?

0

You should ensure that you actually have a unit named xorg.service. To my knowledge, no distribution is starting X this way, so, unless you have written your own xorg.service, there is simply no such unit.

Moreover, let me emphasize that simply starting your service after X server (or after the display manager) is fundamentally not enough to make it communicate with X.

To put it simple, systemd or any other init system is not meant to run user GUI applications. Though it is certainly possible through some degree of hackery, I would not recommend it -- just stick with xinitrc.

0

First of all, as @intelfx said, you should make sure an xorg.service exists. I think a better approach is to refer to graphical.target, which is triggered when the graphical system is up.

If the service is for a user session you should consider using:

systemctl --user enable test.service

This way the service will be triggered when the user that activated it logs in if all the other requirements are met. Mind that your initial approach may happen before any user is authenticated and therefore outside any user session.

If you want to enable the --user service for all users, you can add it on /etc/systemd/user/default.target.wants so it is activated unless the user opts-out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.