7

I am having some issues with auto-starting programs when my Raspberry Pi 2 boots. I have tried editing both /etc/xdg/lxsession/LXDE-pi/autostart & /etx/xdg/lxsession/LXDE/autostart and neither made any difference. I put the following code in both files

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
#@xscreensaver -no-splash
@sh ${HOME}/.config/lxsession/LXDE-pi/autokey.sh
@iceweasel

Are the tutorials I am following outdated or is there another autostart file to edit? My goal is to boot right into a fullscreen web browser in kiosk mode and no mouse.

Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144
svicino
  • 71
  • 1
  • 2
  • If the issue is you get a login screen instead, it is because this will only work at boot if you have autologin enabled. – goldilocks Dec 31 '15 at 21:33
  • Great question. – Alex Lowe Jan 01 '16 at 02:16
  • 1
    @goldilocks I have it configured to boot into the desktop logged in. – svicino Jan 01 '16 at 03:26
  • are you looking for a command to run that will get you there or is this more of a configuration/edit? – 1'' Jan 24 '16 at 08:52
  • "Are the tutorials I am following outdated or is there another autostart file to edit?" Took the words right out of my mouth. I've been at this for four hours now. Five different config files modified later, I still can't get iceweasel to autostart nor can I disable the screen from going black. – Wray Bowling Mar 20 '16 at 18:11

6 Answers6

2

You should edit ~/.config/lxsession/<profile>/autostart if you have it, or make sure it is removed if you need a global LXSession configuration for all users. If you happen to have both files, the global configuration will be ignored:

Commands globally executed are stored in the /etc/xdg/lxsession//autostart file, and in addition, other commands can be locally specified in the ~/.config/lxsession//autostart file. If both files are present, only the entries in the local file will be executed.

If that doesn't help, I would be inclined to check if LXSession is actually used as your session manager (e.g. by checking X11 config files or running ps ax | grep lxsession). I know it sounds silly, but it's not impossible to install e.g. openbox, forget about it, then wonder why LXSession ignores its config files.

Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144
1

In the /etc/xdg/lxsession/LXDE-pi/autostart file, ${HOME} and ~/ don't seem to work. Instead, as a work around, put in an absolute path. The line should therefore look like:

@/home/<you>/.config/lxsession/LXDE-pi/autokey.sh
1

I use crontab because it is simple and equally useful for running all kinds of automated scripts regardless of the Linux/Unix system you happen to be using. This is also answered on this question. Below, my own code:

Open crontab:

sudo crontab -e

Instead of the usual crontab format for date (eg. */5 * * * * script_name) use @reboot:

@reboot sudo python /home/pi/python_scripts/script.py &

I use sudo in both instances because it is required for the script I am running. Thw ampersand & at the end runs the script in the background.

ow3n
  • 111
  • 4
0

If you just want to execute simple commands on boot, run crontab -e to edit commands that can be run at certain times, intervals, or at boot. Each crontab is user specific. If you wanted to run sh ${HOME}/.config/lxsession/LXDE-pi/autokey.sh and iceweasel on boot, simple add the line @reboot sh ${HOME}/.config/lxsession/LXDE-pi/autokey.sh && iceweasel to the end of your crontab file.

jeffresc
  • 199
  • 4
0

I haven't been right through this: http://blogs.wcode.org/2013/09/howto-boot-your-raspberry-pi-into-a-fullscreen-browser-kiosk/ but the approach, using rc.local (I use successfully this for an auto-boot for a personal project) looks plausible. Also, it's fine grained, deals with screen resolution etc.

I wouldn't use crontab for this, that's mainly for timed batch programs, for example, zipping up log files each day and sending them somewhere.

Best regards Hugh

Hugh Barnard
  • 149
  • 3
-1

When Using

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

You are then able to add lines for example:

@/usr/bin/python /home/pi/example.py

Depending what you are running you will need to include the location of what you want to run. You also have to input it in a similar fashion as you would in a terminal. As the previous example you have to call Python before running a python script.

Brett Reinhard
  • 454
  • 1
  • 4
  • 14