6

I want to run a program when my embedded Linux's desktop has started up, in the same way as Windows runs programs in the "Startup" folder. How can I do this?

Specifically, my target hardware is Beaglebone Black, the Debian variant (rev C board). The Window Manager is the default one.

Julian Gold
  • 1,246
  • 2
  • 19
  • 40

2 Answers2

4

In Linux these are called init scripts and usually sit in /etc/init.d. How they should be defined varies between different distros but today many use the Linux Standard Base (LSB) Init Script format.

Good readings on this: https://wiki.debian.org/LSBInitScripts https://www.debian-administration.org/article/28/Making_scripts_run_at_boot_time_with_Debian

marekful
  • 14,986
  • 6
  • 37
  • 59
  • 3
    Not really; the init scripts are more like Windows services, which run regardless of whether you are logged in. Startup items are more like your session manager's session script, which only runs when you start a new session (i.e. log in, or otherwise manage to run the desktop). – tripleee May 05 '15 at 14:45
4

There are multiple ways to start a program, it turns out. LXDE - the window manager - supports auto-start of .desktop files places in either ~/.config/autostart or /etc/xdg/autostart - hooray!

http://wiki.lxde.org/en/Autostart

Except... though I can run a simple program as proof-of-concept in this way, when I try to run mine, it fails. I can't figure out why. The file

.xsession-errors.old

contains X server errors ("resource temporarily unavailable").

I am now using another mechanism - running the code from a shell script (this is necessary because I need to specify a working directory for the program). This uses the "autostart" file in /etc/xdg/lxsession/, and at least it works. Well kind of. I either have to "sleep 5" before running, or prefixing the run with an @ symbol which forces a retry if it fails. It looks a little like something my code is dependent on is not in place at the precise time the autostart mechanism finds it. I can find no way of ensuring startup order. This is plainly a crock of stinky stuff.

Julian Gold
  • 1,246
  • 2
  • 19
  • 40