<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Dec 17, 2014 at 4:34 AM, jenia.ivlev <span dir="ltr"><<a href="mailto:jenia.ivlev@gmail.com" target="_blank">jenia.ivlev@gmail.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello.<br>
<br>
I want to start synapse (its a program that allows to run programs more<br>
easily) at login using systemd. So I created this systemd-service config file:<br>
<br>
[Unit]<br>
Description=Syanpse start up<br>
After=lxdm.service<br>
<br>
[Service]<br>
User=jenia<br>
ExecStart=/usr/bin/synapse<br>
<br>
[Install]<br>
WantedBy=multi-user.target<br>
<br>
I doesnt work neither automatically, nor by calling<br>
/usr/lib/systemd/system/synapse.service as so:<br>
systemctl start synapse<br></blockquote><div><br></div><div>I see that Synapse is an X11 program, gtk-based. The system service manager, whether it was systemd or another init, is not suitable for this because it has no knowledge about the X11 sessions that might be active.</div><div><br></div><div>(Indeed, "After=lxdm.service" won't actually make it start _at login_, but at the time the welcome screen shows up.)</div><div><br></div><div><tldr></div><div><br></div><div>Remember that by design there can be zero or several people running their own X11 servers at once; programs therefore need to know environment variables like $DISPLAY (and several others) to choose the right one. That's why you get this:</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> Dec 16 21:23:11 station1 synapse[8545]: [02:23:11.040620 Gtk-Warning] cannot open display:<br></blockquote><div><br></div><div>Setting these variables statically in your .service would be a poor idea since they can change (some of them _do_ change every time lxdm starts), not to mention being exactly the kind of ugly hack that systemd tries to avoid.</div><div><br></div><div>(And while systemd _is_ trying to eventually reach the point where simply setting User= should be enough to discover all such information, it still wouldn't help you, because your service still starts together with lxdm, _before_ you actually log in.)</div><div><br></div><div></tldr></div><div><br></div><div>For now, it will be easiest to start such services from your desktop environment, as it already runs inside your graphical login and therefore knows all the necessary settings.</div><div><br></div><div>Whether you use GNOME or Enlightenment or LXDE or a custom-built environment on top of a tiny tiling WM, they all have ways to autostart programs. Most of them support the XDG <a href="http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html">Autostart</a> specification. Put this in ~/.config/autostart/synapse.desktop:</div><div><br></div><div>[Desktop Entry]</div><div>Type=Application</div><div>Name=Synapse</div><div>Exec=/usr/bin/synapse</div><div> </div></div>-- <br><div class="gmail_signature"><div dir="ltr">Mantas Mikulėnas <<a href="mailto:grawity@gmail.com" target="_blank">grawity@gmail.com</a>></div></div>
</div></div>