We can launch applications and scripts as services during boot at various Linux run-levels as demonstrated earlier, however at-times we need to launch applications or perform scripted tasks only after the Graphical interface is loaded. For example in my usage scenario with Debian running on a Raspberry Pi, few services were failing to work as expected when launched using inti.d method as they require the host to be properly connected to the internet which only happened (in my usage scenario) after the GUI started loading.
Here is another handy way to auto-launch applications and scripts in a similar manner to "autostart" in Windows, we will be using LXDE "/home/pi/.config/autostart" folder to create shortcuts which will launch our executable after GUI starts loading.
Steps to create LXDE autostart shortcut :
- To get this working simply create an anyname.desktop file inside /home/pi/.config/autostart folder having the prescribed format as shown below.
- The above myscript.desktop shortcut will make LXDE load /home/pi/Desktop/mystart.sh after it gets loaded, the mystart.sh bash script in this case holds all the applications and tasks which I need to get executed on boot.
- Here are the contents of mystart.sh for reference.
[Desktop Entry] Type=Application Exec=/home/pi/Desktop/mystart.sh
#!/bin/sh -e
sudo ntpd -qg
sudo service aria2cRPC start
Comments
Alternative
I tried this method and didn't work for me on Raspian. What I ended up doing was:
1. Edit /etc/xdg/lxsession/LXDE-pi/autostart
2. Append this line:
@lxterminal -e /path/to/my/script.sh
I hope this helps.
Peace out \m/
Add new comment