1

I am trying to get firefox-esr to open at startup. I successfully installed & updated Raspbian Stretch.

The easy code version was to add @firefox-esr to the bottom of:

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

This didn't work, which surprised me. So after reading some here, I tried what looked like a more foolproof run.

I have two scripts in:

/home/pi/

First one: start_firefox.sh

/bin/sleep 13
sudo -u pi firefox-esr
/bin/sleep 3
xdotool key F11

Second one: start_REfresh.sh

/bin/sleep 15
/usr/bin/lxterminal --command watch -n 3600 xdotool key ctrl+F5 &

Now, I have tested the first one in terminal with /home/pi/start_firefox.sh and it opens firefox though doesn't seem to engage the fullscreen.

I ran these to make it executable:

sudo chmod 755 start_REfresh.sh
sudo chmod +x start_REfresh.sh
sudo chmod 755 start_firefox.sh
sudo chmod +x start_firefox.sh

So I change my autostart file sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

And it includes these:

@/home/pi/start_REfresh.sh
@/home/pi/start_firefox.sh

But it doesn't work. Am I using the wrong autostart file? If it matters, I'm using Stretch 9.2. Thank you for your guidance!

  • 1
    Is there anything in your local user autostart file? (you can check with nano ~/.config/lxsession/LXDE-pi/autostart; if the file isn't empty you know it exists) If there are contents in that file, the autostart file in /etc is ignored if I remember correctly. – Aurora0001 Jul 29 '18 at 15:44
  • That did it! Now to figure out why xdotools isn't working – Matt Cottrill Jul 29 '18 at 16:16
1

The global autostart file, /etc/xdg/lxsession/LXDE-pi/autostart, is ignored if you have a local autostart file in your home directory, ~/.config/lxsession/LXDE-pi/autostart. If you have a local autostart file, you need to use that instead of the global one (or remove the local autostart file). Anything you put in the global autostart file will be ignored if a local file exists. You can edit your local autostart file with:

nano ~/.config/lxsession/LXDE-pi/autostart 

(or use your editor of choice). If the file does not yet exist, you can rule this out.


As for your xdotool issue, I suspect the issue is that /bin/sleep 3 is not sufficient. If Firefox isn't ready to accept the F11 press in three seconds, your script will fail. As noted in the documentation you can use search --sync to wait for a window to exist:

xdotool search --sync --onlyvisible --class "firefox"

Another issue is that by calling firefox-esr from the terminal, it will probably block until Firefox exits, so your sleep and xdotool call won't be run until Firefox exits. You can launch firefox-esr in the background with:

sudo -u pi firefox-esr &

Combining all of the changes:

/bin/sleep 13
sudo -u pi firefox-esr &
/bin/sleep 3
xdotool search --sync --onlyvisible --class "firefox" windowfocus key F11

Note the search --sync to find Firefox, then windowfocus to it, and then send the F11 key. This should ensure that the F11 event is sent as expected.

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.