2

I need to run Midori automatically on power on.

If I run it via: /etc/xdg/lxsession/LXDE/autostart

it launches OK but seems to get launched twice

So I then tried launching it from /etc/rc.local

However if I do this I get the error message:

Midori - Cannot open display:

Maybe rc.local launches at a different time to autostart?

Any ideas why I get the error message "CANT OPEN DISPLAY"?

  • Have you solved your problem? If so, please mark the answer that helped you, or if you solved it on your own, create a self-answer and mark it as such. We are trying to get the site Q:A ratio up and marking answers is what does that. If you resolved it and mark then people in the future will be able to profit from what you did and it helps move the site closer to graduation. Thanks! – RPiAwesomeness Mar 23 '14 at 16:49
  • nope didnt solve it – spiderplant0 Mar 25 '14 at 23:13
  • Can't you set a simple script in the autostart that pkill -9's the second Midori that gets launched? – RPiAwesomeness Mar 26 '14 at 3:00
2

You can't run a program which need run on X via /etc/rc.local file. You should use LXDE autostart configuration.

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

http://wiki.lxde.org/en/LXSession#Automatically_start_some_applications_on_login

• Create the folder /home/pi/.config/lxsession/LXDE
• Put a file named autostart in this folder, specifying the full path of the file to be executed:
e.g. python /home/pi/pirun.py

• Make the autostart file executable by chmod +x /home/pi/.config/lxsession/LXDE/autostart

  • Thnaks got this to work. But, like the autostart in /etc, the commands in the autostart in my home directory are getting launched twice. – spiderplant0 Sep 28 '13 at 17:15
1

When started from rc.local Midori is starting before the X server (the graphical display manager) has started. So when Midori starts it cannot attach to the display and you get the error.

Using autostart seems like the right way to do it but I'm not familiar with it so I can't help you with that.

  • Thanks Craig, I should have said, from rc.local and autostart, I'm actually launching a python script which launches Midori only when the server appears, so I can delay when Midori launches, but it still gets the same error message. – spiderplant0 Sep 26 '13 at 22:49
  • Do you know of any other scripts that are run after the X server has started? – spiderplant0 Sep 26 '13 at 22:50
1

The programs started from /etc/rc.local don't have the $DISPLAY environment variable set, even if you're starting them with a delay so that they launch after X does. Just add

export DISPLAY=:0.0

to /etc/rc.local before you start calling your commands and you should be OK.

-4

Try to Install xinit, like so:

sudo apt-get install xinit
  • How exactly does this help? – Steve Robillard Jan 25 '16 at 7:26
  • Welcome to Raspberry Pi! Whilst this may theoretically answer the question, it would be preferable to include some explanation here, e.g. what do this command do? How does it work and why is it related to the question? – Ghanima Jan 25 '16 at 7:51
  • 1
    -1 This seems unlikely to be any help - and as most GNU/Linux distributions, including the default Raspbian Jessie (at the time of writing) has switched to systemd attempting to install the older system V init on to such a system is likely to break things if not done very carefully. Recommendation to others: don't try this action unless you really know why you should do it and the OP's question is not one where you should IMHO! – SlySven Jan 25 '16 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.