Menu Close

Autostart a bash script after auto login

If you have installed a Raspian Linux image with a GUI (aka LXDE Desktop or the X window environment) you can automatically start scripts after this environment has been loaded. Make sure you have auto login enabled.

Open your terminal and create a new file:

sudo nano /etc/xdg/autostart/startme.desktop

In the /etc/xdg/autostart folder there are more *.desktop files available. We created a new one named ‘startme’. You van use whatever you like as the script name.

In the startme.desktop file add the following code:

[Desktop Entry]
Name=MyScriptToStart
Exec=/home/pi/myscript.sh

Change the ‘Name’ in something you can recognise.

In the ‘Exec’ part you can place the location of the script you want to execute.

Save the file with CTRL+X and press Y.

Reboot the PI and see the magic happens.

Related Posts

Leave a Reply

Your email address will not be published.