grizzlyadams
Posts: 4
Joined: Thu Oct 01, 2015 11:05 pm

Can I delay chromium in kiosk mode?

Thu Oct 01, 2015 11:20 pm

Hi.

I'm setting up a pi to run in kiosk mode as per the instructions in https://github.com/basdegroot/raspberry-pi-kiosk. Everything works as required. My pi is also running an Express server with a bunch of things behind it, that also works. But ... my Express instance is a bit slow starting up, and is not ready by the time Chromium in kiosk mode has loaded and looks for its intended URL. Is there some way I can delay the chromium startup process so Express has a chance to load?

My X startup script looks like

Code: Select all

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xset s off
@xset -dpms
@xset s noblank
@sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' ~/.config/chromium/Default/Preferences
@chromium --noerrdialogs --kiosk http://127.0.0.1:3000/demo.html
I tried adding "sleep 5s" but I'm guessing that's not valid in this context. Any suggestions? Totally alternative routes are also good, even if it means a bit of coding, as long as it gets me there. Thanks!

firstness
Posts: 20
Joined: Thu Oct 01, 2015 2:36 am

Re: Can I delay chromium in kiosk mode?

Fri Oct 02, 2015 3:36 am

Not sure if this would work but you could replace the chromium entry with a Bash script.

Code: Select all

#!/bin/bash
echo "Starting chromium in 5 seconds..."
sleep 5
chromium --noerrdialogs --kiosk http://127.0.0.1:3000/demo.html &
Save the above to /home/pi/start-chromium.sh (note the addition of & at the end of chromium line to start chromium as a background process, thus allowing the script to end immediately instead of waiting for chromium to close)

"Run chmod u+x start-chromium.sh" to give execute permission.

Replace chromium line in X startup script with "@/home/pi/start-chromium.sh"

grizzlyadams
Posts: 4
Joined: Thu Oct 01, 2015 11:05 pm

Re: Can I delay chromium in kiosk mode?

Fri Oct 02, 2015 5:40 pm

Thanks firstness, that did exactly what I needed. Also, I learned how to call a bash script which I'm pretty sure I'll be using in the future. Much obliged.

firstness
Posts: 20
Joined: Thu Oct 01, 2015 2:36 am

Re: Can I delay chromium in kiosk mode?

Fri Oct 02, 2015 6:08 pm

No problem. I was also thinking that if chromium ever crashes you could have it restart automatically by editing the script like this:

Code: Select all

#!/bin/bash
echo "Starting chromium in 5 seconds..."
sleep 5
while :
    do
        chromium --noerrdialogs --kiosk http://127.0.0.1:3000/demo.html
done
The script would stay running forever and restart chromium if it ever closes. I'm not sure if this would cause a problem with the X startup script considering it never exits but it could be worth a try. To end the script you would run "ps aux" to find the process id of the script and "kill [pid]"

grizzlyadams
Posts: 4
Joined: Thu Oct 01, 2015 11:05 pm

Re: Can I delay chromium in kiosk mode?

Fri Oct 02, 2015 9:58 pm

Thanks again Firstness, that's another cool trick I've learned (this is my first week in Linux land).

For what it's worth, I switched Chromium for Epiphany (using xautomation to F11 full screen it after launch). Chromium 22 was too buggy to render my bleeding edge CSS3 animations.

firstness
Posts: 20
Joined: Thu Oct 01, 2015 2:36 am

Re: Can I delay chromium in kiosk mode?

Sat Oct 03, 2015 12:26 am

By the way you can try installing Chromium 45 if you have the newest Raspbian Jessie.

viewtopic.php?uid=160930&f=63&t=121195& ... 30GKU6JBE7

Bambamj
Posts: 3
Joined: Fri Nov 06, 2020 2:14 am

Re: Can I delay chromium in kiosk mode?

Fri Nov 06, 2020 12:47 pm

this is an old post but im doing the same could. I add this to the .bashrc file instead. thats where I have this code to get it to launch

Code: Select all

[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor

Return to “General discussion”