wbickle
Posts: 8
Joined: Wed Mar 02, 2016 2:41 am

Chromium Auto Refresh

Wed Mar 22, 2017 2:59 pm

Running the current version of Pixel on my Pi 3, is it possible to add something to the crontab file which will auto refresh the open Chromium page on a scheduled basis?

TIA.

Bill

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5354
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Chromium Auto Refresh

Wed Mar 22, 2017 3:30 pm

There are chrome addons that can do this. Does this work?
https://chrome.google.com/webstore/deta ... njkc?hl=en

wbickle
Posts: 8
Joined: Wed Mar 02, 2016 2:41 am

Re: Chromium Auto Refresh

Sat Mar 25, 2017 2:38 pm

Yes! Thanks so much.

Bill

relayman357
Posts: 2
Joined: Mon Nov 06, 2017 3:28 pm

Re: Chromium Auto Refresh

Mon Nov 06, 2017 3:30 pm

You may want to check this out before using that extension: https://www.youtube.com/watch?v=9k0wqHMOyD0

This suggests rather convincingly that it is malware.

relayman357
Posts: 2
Joined: Mon Nov 06, 2017 3:28 pm

Re: Chromium Auto Refresh

Mon Nov 06, 2017 3:39 pm

Also, if you just need to refresh a local html file then just embed the following meta line in your html file:

<META HTTP-EQUIV="refresh" CONTENT="30"> <! -- This is to force refresh of this page every 30 seconds>

Leon71
Posts: 1
Joined: Sun Nov 26, 2017 10:41 am

Re: Chromium Auto Refresh

Sun Nov 26, 2017 3:11 pm

I have solved it with xdotools

I copied the autostart file from /etc/xdg/lxsession/LXDE-pi/autostart to /home/pi/.config/lxsession/LXDE-pi/autostart with the command:
cp /etc/xdg/lxsession/LXDE-pi/autostart /home/pi/.config/lxsession/LXDE-pi/autostart

After that, I edited the local version:
sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart :

@xscreensaver -no-splash
@xset s off
@xset -dpms
@xset s noblank
@chromium-browser --incognito --kiosk http://www.yoursite.com # load chromium after boot

Next, create a file called 'autorefresh-chromium.sh' in /home/pi/ #or any folder you like
chmod the file with the command: chmod 755 /home/pi/autorefresh-chromium.sh to make it exetcutable

Open /home/pi/autorefresh-chromium.sh

Add the following lines:

#!/bin/bash
while true; #create an infinite loop
do
sleep 1200 #refresh time in seconds so 1200 = every 20 min
xdotools key = ”ctrl+F5” & #you need to have xdotools installed
done

Add @/home/pi/autorefresh-chromium.sh to /home/pi/.config/lxsession/LXDE-pi/autostart.
So the file looks like this:

@xscreensaver -no-splash
@xset s off
@xset -dpms
@xset s noblank
@chromium-browser --incognito --kiosk http://www.yoursite.com # load chromium after boot
@/home/pi/autorefresh-chromium.sh

This worked for me

MWZotti
Posts: 9
Joined: Wed Mar 14, 2018 9:52 pm

Re: Chromium Auto Refresh

Wed Mar 28, 2018 1:57 am

Leon71 wrote: I have solved it with xdotools

I copied the autostart file from /etc/xdg/lxsession/LXDE-pi/autostart to /home/pi/.config/lxsession/LXDE-pi/autostart with the command:
cp /etc/xdg/lxsession/LXDE-pi/autostart /home/pi/.config/lxsession/LXDE-pi/autostart

After that, I edited the local version:
sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart :

@xscreensaver -no-splash
@xset s off
@xset -dpms
@xset s noblank
@chromium-browser --incognito --kiosk http://www.yoursite.com # load chromium after boot

Next, create a file called 'autorefresh-chromium.sh' in /home/pi/ #or any folder you like
chmod the file with the command: chmod 755 /home/pi/autorefresh-chromium.sh to make it exetcutable

Open /home/pi/autorefresh-chromium.sh

Add the following lines:

#!/bin/bash
while true; #create an infinite loop
do
sleep 1200 #refresh time in seconds so 1200 = every 20 min
xdotools key = ”ctrl+F5” & #you need to have xdotools installed
done

Add @/home/pi/autorefresh-chromium.sh to /home/pi/.config/lxsession/LXDE-pi/autostart.
So the file looks like this:

@xscreensaver -no-splash
@xset s off
@xset -dpms
@xset s noblank
@chromium-browser --incognito --kiosk http://www.yoursite.com # load chromium after boot
@/home/pi/autorefresh-chromium.sh

This worked for me
I copied these directions then wondered why this didn't work. So just to clarify for all others that may want to use this..... you need xdotool and change the line to:

Code: Select all

export XAUTHORITY=/home/pi/.Xauthority; export DISPLAY=:0; xdotool key "your key combination here" & 
The latest key combos according to google support https://support.google.com/chrome/answer/157179?hl=en :
Reload current page: F5 or Ctrl+r
Reload the current page, ignoring cached content: Shift+F5 or Ctrl+Shift+r

User avatar
Gerrelt
Posts: 294
Joined: Sat Nov 10, 2012 9:01 am

Re: Chromium Auto Refresh

Tue Apr 10, 2018 6:47 pm

I didn't get this working either, even with the tip from MWZotti. But he did point me in the right direction for the solution, thank you MWZotti!
The problem is that xdotools doesn't work under the root user without setting Xauthority.
And adding it to LXDE autostart will make it run under root.

I solved it by creating another script that will set Xauthority for the root user. This script has to be executed before the autorefresh script.

Instructions:

Install xdotools:

Code: Select all

sudo apt-get install xdotool
Next create a script called "xauth_root.sh":

Code: Select all

cd /home/pi
sudo nano xauth_root.sh
Then add these lines to it:

Code: Select all

#!/bin/bash

#
# source: https://raspberrypi.stackexchange.com/questions/1719/x11-connection-rejected-because-of-wrong-authentication
#
touch /root/.Xauthority
xauth merge /home/pi/.Xauthority
export XAUTHORITY=/root/.Xauthority

Make it executable:

Code: Select all

sudo chmod 755 xauth_root.sh
Now create this auto refresh script:

Code: Select all

sudo nano autorefresh-chromium.sh
Add these lines:

Code: Select all

#!/bin/bash

#
# also see instructions here: https://www.raspberrypi.org/forums/viewtopic.php?t=178206#p1239241
#
# To make this run with sudo (which is the case when run at boot), execute "xauth_root.sh" before running this script.
#
# xdotools setup instructions found here: http://theembeddedlab.com/tutorials/simulate-keyboard-mouse-events-xdotool-raspberry-pi/
#

# This will only set up the DISPLAY variable for one command
DISPLAY=:0 xdotool key "ctrl+F5"

# This will set up the DISPLAY variable for every command executed on this terminal,
# and child processes spawned from this terminal
export DISPLAY=:0

while true; #create an infinite loop
do
  xdotool key "ctrl+F5" &
  sleep 300 #refresh time in seconds so 300 = every 5 min
done
(note that this will refresh it every 5 minutes)

Make it executable:

Code: Select all

sudo chmod 755 autorefresh-chromium.sh
Open the LXDE autostart file:

Code: Select all

sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart
And add these three lines to the end (set the desired URL in the first line):

Code: Select all

@chromium-browser --incognito --kiosk http://someURL.youwanttodisplay.com # load chromium after boot
@/home/pi/xauth_root.sh
@/home/pi/autorefresh-chromium.sh
This worked for me!

(see urls in scripts for sources)
my Raspberry Pi page: http://raspberry.gerrelt.nl

PaoloM
Posts: 5
Joined: Tue May 14, 2019 7:20 am

Re: Chromium Auto Refresh

Thu Jun 13, 2019 12:32 pm

Hi guys, is it possible to set only 1 refresh of chromium only at startup?

k0kster
Posts: 10
Joined: Tue Sep 03, 2019 9:02 am

Re: Chromium Auto Refresh

Mon Sep 09, 2019 2:39 am

relayman357 wrote:
Mon Nov 06, 2017 3:39 pm
Also, if you just need to refresh a local html file then just embed the following meta line in your html file:

<META HTTP-EQUIV="refresh" CONTENT="10"> <! -- This is to force refresh of this page every 30 seconds>
hi!

i tried adding the above line into the html file by opening it with chrome and pressing f12.

my head looks like this

https://drive.google.com/open?id=1spQ5B ... HPZMQMpDAA

however, 10 seconds later the meta line diasppears after being refreshed.

Return to “Beginners”