Megaleecher.Net

Making technology work for you...

Get Your Free Subscription By Email:

Autostarting Applications and Scripts After Launch Of LXDE GUI

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.

LXDE autostart

Steps to create LXDE autostart shortcut :

  1. To get this working simply create an anyname.desktop file inside /home/pi/.config/autostart folder having the prescribed format as shown below.
  2. [Desktop Entry]
    Type=Application
    Exec=/home/pi/Desktop/mystart.sh
    
  3. 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.
  4. Here are the contents of mystart.sh for reference.
  5. #!/bin/sh -e
    sudo ntpd -qg
    sudo service aria2cRPC start
    

Comments

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

This is just one of the many helpful tips we have posted, You can find more stories here,
Do subscribe to updates using your favorite RSS feed reader or using the secure FeedBurner email update form on top of this post.