Autostart Application in Raspbian

I needed to set up the Raspberry PI to autostart a PDF slideshow when the system is booted. Raspbian has the app XPDF pre-installed, but it doesn’t have the slideshow feature. To solve this issue I installed Okular. Here’s how I did it (there are two methods).

First install Okular:

sudo apt-get update
sudo apt-get install okular

Now we’re ready to set up.

Method 1

This method uses a global list of autostart applications that applies to all user accounts. They will load whenever LXDE is loaded regardless of whatever user is logged in at the time. Usually this user is the default ‘pi‘ account.

Edit the file ‘/etc/xdg/lxsession/LXDE/autostart‘ as ‘root‘ user:

sudo vi /etc/xdg/lxsession/LXDE/autostart

After the last line, add a line for each application you wish to autorun. For example, if I add a line for Okular to open a pdf file in slideshow mode (--presentation) my file looks like this:

@lxpanel --profile LXDE
@pcmanfm --desktop --profile LXDE
@xscreensaver -no-splash
@okular /path/to/file.pdf --presentation

Method 2

The alternative method is to create a configuration file that is unique to the current logged in user.

mkdir -p ~/.config/lxsession/LXDE
vi ~/.config/lxsession/LXDE/autostart

As in Method 1 this file represents a list of commands to be executed when the GUI loads. So just add the applications you need to auto-load:

@okular /path/to/file.pdf --presentation

Now when the system start/reboot, the slideshow will start automatically.

That’s it.