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.
With the file location open, press the Windows logo key + R, type shell:startup, then select OK. This opens the Startup folder.
Accessing The Windows 10 Startup Folder Open the File Explorer and drop one of the following paths into the Quick access bar. The All Users Startup Folder is located at the following path: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp.
These programs start up for all users. To open this folder, bring up the Run box, type shell:common startup and hit Enter. Or to open the folder quickly, you can press WinKey, type shell:common startup and hit Enter. You can add shortcuts of the programs you want to start with your Windows in this folder.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With