7

I'm running raspbian on pi. I've created a systemd script which runs a node.js app on startup.

Script:

#!/usr/bin/env bash
cd /home/pi/pop_machine && /usr/bin/npm start

Systemd Service:

[Service]
ExecStart=/home/pi/pop_machine/start_pop.sh

[Install]
WantedBy=default.target

The script works if I run it manually but not on startup. I'm wondering if it's because it tries to run before its dependencies.

I've seen people require networking before running by adding a line to [install] is there something similar where I can wait until everything to run a GUI application is ready?

I assume I just need x-window?

1 Answer 1

9

Solved by adding these to service:

[Service]
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/pi/.Xauthority"

[Install]
WantedBy=graphical.target
4
  • Probably you also enable and start it. You didn't use .timer?
    – Pablo A
    Dec 21, 2018 at 23:00
  • I'm on Ubuntu and that graphical.target works great. I also have the Environment="DISPLAY=:0". However, the .Xauthority, I did not try with that one. I don't think it's saved at that location anymore anyway. Jul 2, 2021 at 16:49
  • @PabloA Why would you start a GUI app. on a timer?! Jul 2, 2021 at 16:51
  • 1
    This was long time ago, I'm not sure what I meant with the timer. BTW, could be useful on some cases. Also, you probably enabled the service also, you could mention that (obvious, though). Did you mean you didn't try without .Xauthority? If it's necessary, could be useful its content.
    – Pablo A
    Jul 2, 2021 at 21:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .