I want to refresh the browser, like pressing the F5 or Ctrl+F5 key on the keyboard with a shell script.
I´m new in writing shell scripts so i aks you to help me with this:
when I type in this into the command line, the refresh works perfectly:
DISPLAY=:0 xdotool getactivewindow key F5
I wrote a script refresh.sh with this content:
export DISPLAY=:0.0
xdotool getactivewindow
xdotool key F5
But it reurns:
pi@babaloo ~ $ sudo sh /var/www/refresh.sh
No protocol specified
Error: Can't open display: (null)
Failed creating new xdo instance
No protocol specified
Error: Can't open display: (null)
Failed creating new xdo instance
can someone give me a hint?
Chromium Browser is in Kiosk mode, here is my
/etc/xdg/lxsession/LXDE/autostart
-
#@lxpanel --profile LXDE
#@pcmanfm --desktop --profile LXDE
#@xscreensaver -no-splash
@xset s off
@xset -dpms
@xset s noblank
@chromium --kiosk --incognito http://localhost/output/output.php?monitor=1
~~ EDIT:
I changed my script to
export DISPLAY=:"0.0"
XAUTHORITY=/home/pi/.Xauthority
xdotool getactivewindow
xdotool key F5
when i start it from console with
sh /var/www/refresh.sh
it works!
But now i want to execute this script by PHP with user www-data. Therefor i added to visudo:
www-data ALL=(ALL) NOPASSWD: ALL
www-data ALL=(ALL) NOPASSWD: /var/www/refresh.sh
and Created a PHP-File with this content:
<?php
exec("sudo sh /var/www/refresh.sh");
?>
<h1>Refreshing output</h1>
But nothing happend...
Is there a chance to get more informations about the returning errors? I found nothing in documentation for "exec"-command.
Also tried:
<?php
$output = array();
$output[] = exec("sudo sh /var/www/refresh.sh");
print_r($output)
?>
but the returning array is empty
window.location.reload(false);
-You use a timer, or ajax to control when to refresh. Since you have PHP running to execute the page you are viewing I assume the page you want to refresh is your page...killall chromium
and restart the application after... but i thin it´s a more "overkill".