30

I am automating a RPi for four displays at my company. I have them rebooting every day so the browser will refresh. I can't get the Restore pages? Chromium didn't shut down correctly bubble to not come up. I've tried several solutions that ive found online, but nothing works.

Ive added many switches such as --noerrdialogs --disable-session-crashed-bubble --disable-infobars --disable-restore-session-state --incognito

Ive also tried a couple of sed commands i found online.

Any help would be greatly appreciated.

Paul Karvetski
  • 321
  • 1
  • 3
  • 4
  • 1
    Have you looked into properly shutting down chrome? – Steve Robillard Jun 20 '17 at 13:55
  • the reason I suggest this is it is treating the disease, not the side effects. – Steve Robillard Jun 20 '17 at 14:33
  • I was thinking about a cronjob to shut down chromium 10 minutes before the reboot runs. Thats the next step, any suggestions? – Paul Karvetski Jun 20 '17 at 15:34
  • That may work especially if scripted through the GUI and a check is added before your reboot. You may also be able to avoid the reboot completely. If they are only displaying a single page you may want to look at fullpageOS. – Steve Robillard Jun 20 '17 at 15:38
  • The only reason for the reboot, is I haven't found an automated way to refresh the pages. If there is a way to refresh the page while in kiosk mode, i wouldn't need the reboot. – Paul Karvetski Jun 20 '17 at 15:45
  • 2
    you can use javascript to refresh after a certain amount of time https://stackoverflow.com/questions/2787679/how-to-reload-page-every-5-second you likely don't need to refresh every 5 seconds but the theory is the same. – Steve Robillard Jun 20 '17 at 15:48
  • Thats where it gets beyond my skill set. – Paul Karvetski Jun 20 '17 at 15:53
  • 1
    In that case, I suggest you edit your question so it describes the problem not the symptom and asks for methods of solving the problem. Alternatively, you could delete this question and ask a new one. One important point is do you control the web pages? – Steve Robillard Jun 20 '17 at 16:21
  • The only thing I would add to that, is there are many ways to solve a problem with Linux. My problem is I want to get rid of that notification. I just need a bit of an easier way to do it than the knowledge you have shared, which I greatly appreciate your quick responses. – Paul Karvetski Jun 20 '17 at 16:36
  • 1
    Sounds like you're looking at a classic XY problem. You've effectively asked us, HELP! I don't know how to use the brake pedal so I stop my car by crashing the car into things. How do I disable the airbag? You need to focus on writing a webpage that does what you need it to do. – Jacobm001 Jun 20 '17 at 18:08
  • I was having the same issue with a windows 7 box that I needed to run a kiosk page on. I setup a time sensitive kill task, then a run task, but after the run task, I would get the "Chrome didn't shut down correctly" popup. Just adding "--incognito" after the --kiosk worked for me. – oOJustmeOo Dec 27 '17 at 15:46

9 Answers9

36

I've got it! Use --app=your.url

For example:

chromium-browser --kiosk --app=http://your.url.here
Greenonline
  • 2,740
  • 4
  • 23
  • 36
Fabiano Cores
  • 461
  • 4
  • 2
9

For those arriving here from Google:

The best way to now perform this task, without having to use incognito, is to adjust two settings in the Chromium preferences. They are:

  • exited_cleanly
  • exit_type

From what I have gathered from personal tests, just changing the "exited_cleanly" setting may not always work at preventing the Chromium prompt on startup. Other flags such as -disable-infobars will also not work.

To adjust these settings, please add the following in your startup file, before launching Chromium (depending on how you have set up Chromium to automatically run in kiosk mode, this file can either be located at /etc/xdg/lxsession/LXDE-pi/autostart, /etc/xdg/openbox/autostart, ~/.Xsession, or another file, depending on what you have already installed).

sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/Default/Preferences
sed -i 's/"exit_type": "Crashed"/"exit_type": "Normal"/' ~/.config/chromium/Default/Preferences

For example, with my setup (using Xsession), the procedure would go as follows:

  1. Enter sudo nano ~/.Xsession into the console
  2. Insert the above 2 lines into the file, before Chromium is run (You should see a line starting with chromium-browser, so insert them above this)
  3. Press Ctrl + X to exit the file
  4. Type Y
  5. Press Enter
  6. Reboot the machine

Again, the file used to start up Chromium may be located in a different location, depending on how you have setup your Pi, but after changing these two settings, Chromium should start up without displaying the crashing prompt.

Greenonline
  • 2,740
  • 4
  • 23
  • 36
Wincruzer
  • 91
  • 1
  • 3
  • I'd like to use jq to achieve the same goal: jq '.profile.exit_type= "Normal" | .profile.exited_cleanly = true' ~pi/.config/chromium/Default/Preferences > ~pi/.config/chromium/Default/Preferences – Huan Sep 02 '20 at 17:40
  • Note that the sed script still works after one removes the spurious space in "exit_type": "Crashed". It should read "exit_type":"Crashed". I would edit the answer myself but StackExchange says I have to edit more than six characters, which is a silly restriction. – hackerb9 Oct 24 '21 at 05:28
6

1) I dunno why --disable-infobars didn't work for you. This works well for me:

chromium-browser --kiosk --disable-infobars \
http://URL1 \
http://URL2 \
http://URL3

2) A better way to refresh the browser (contents) would be to sent it Control-R? e.g. in your browser startup script, do:

(while sleep 200; do xdotool key ctrl+R; done) &

(I also send ctrl+Tab to cycle through my multiple browser tabs

Nigel Pearson
  • 61
  • 1
  • 2
6

I know this doesn't really solve the issue - but as a work-around - it did the trick for me.

I made sure Chrome was shut down cleanly... Opened terminal

cd .config/chromium/Default
chattr +i Preferences

This makes the file immutable... strictly read-only, Chrome can crash as much as it likes - it wont show the popup as the Preferences file can no longer be changed.

This setup works for me as the Pi config will not change - it's just displaying a web based app in kiosk mode.

Aurora0001
  • 6,308
  • 3
  • 23
  • 38
  • Works in Linux Distros too... Note that there could be issues in Windows / WebDriver / Selenium as reported elsewhere – MarcoZen Aug 21 '18 at 13:42
3

To disable the Restore Pages bubble I open chromium twice in the autostart file like this:

chromium-browser --no-startup-window --kiosk
chromium-browser --noerrordialogs --kiosk http://your.url.here

The first one gets the popup bubble but you don't see it, then the second one opens as if browser was closed successfully. Probably not the cleanest way to do this, but it worked for me.

MD004
  • 103
  • 2
  • This method, although blunt, is the only answer on this page that works for me. I'm loading Chromium from Selenium, and I need to use a specific user profile with it. Quitting and reloading the browser via Selenium did the trick! – Henry Cooke Aug 04 '20 at 20:57
  • 1
    This is also the only method that worked for me. In my situation, I do not wish to use Kiosk mode, but this still seems to do the trick. Thanks for the idea! – GreatBlakes Aug 25 '21 at 00:11
2

I came up with a workaround that actually took care of several items at once.

vi restartscript.sh

#!/bin/sh
/usr/bin/killall chromium-browser
/usr/bin/apt-get update -y
/usr/bin/ apt-get upgrade -y
/sbin/reboot

Make the script executable: chmod +x restartscript.sh

Edit cron: chrontab -e

0 5 * * * /home/pi/restartscript.sh

The webpage im displaying gets refreshed, and the pi stays up to date.

MatsK
  • 2,791
  • 3
  • 16
  • 20
Paul Karvetski
  • 321
  • 1
  • 3
  • 4
2

My solution is very easy. I only copy a Preferences file from a former clear shutdown of Chromium over the current file ~/.config/chromium/Default/Preferences.

Aurora0001
  • 6,308
  • 3
  • 23
  • 38
2

The only way that worked for me was to modify the config before starting Chromium:

sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/Default/Preferences
Mikey
  • 21
  • 1
  • 1
    Chrome has changed their flags a lot since most of the posts on the internet. Having tried it all I took this approach. You also need to sed: 's/"exit_type":"Crashed"/"exit_type":"Normal"/' – run_the_race Oct 29 '20 at 20:39
2

This page gave me the answer. Adding the option

chrome_options.add_argument("--profile-directory=Default")

resolved it for me (in a non-kiosk application).

Turns out this was only part of the issue. The whole situation seems very variable. I additionally added:

prefs = {'exit_type': 'Normal'}
chrome_options.add_experimental_option("prefs", {'profile': prefs})

Trying to reproduce the error to prove this was the fix, I can't now get it to come back with the pop-up (even without this code). YMMV, btw this is running version 72 of Chrome. I saw other posts that advocated changing the Preferences file with something like sed before starting the browser.

Bryan
  • 341
  • 1
  • 2
  • 8