1

Total noob to RPi and Python... and this message board, for that matter. Please excuse any inappropriate behavior on this, my first posting.

The solution provided by xxmbabanexx did EXACTLY what I need in this post: Auto-refresh for Midori

The only thing I need is for Midori to start in fullscreen mode.

I did some hacking in the line of the code: sub.Popen(["midori", "-a", page_to_open_to]) #open midori.

But when I did change anything, it just stopped working.

I researched the proper Python syntax for Popen but it blew my mind.

Could anyone, or the genius himself xxmbabanexx, help me over this last hurdle?

1 Answers1

0

Don't mess with this line:

sub.Popen(["midori", "-a", page_to_open_to]) #open midori

That is opening the process and is not what you are looking to modify. Here is what you want to do:

sub.call(["midori", "-e", "Fullscreen"])

After opening Midori (the line you were trying to modify/"hack"). Here is the code (not tested):

"""
Midori Kiosk Reloader.
Created by xxmbabanexx

NOTE: This program opens Midori automatically. DO NOT OPEN IT MANUALLY, SIMPLY CLICK ON THIS PROGRAM.

KEYS

1 = Connection Complete. All is well.

0 = Connection Incomplete. Something is wrong.
"""


#Change these variables to your liking.

host = "www.google.com" #Put your desired host URL/IP between the quotes

port = 80 #Set to default port of 80. If your host uses something else, please change it.

recheck_time = 10 #The number of seconds the program will wait to ping the server. Change this at your leisure.

page_to_open_to = "www.google.com" #This is the webpage the kiosk will open to. Put the url between the quotes.


#Excersise caution when changing these vars.

last = -1 #undefined state
up = -1 #Undefined state



"""
#---------------- Main code. Do NOT touch unless you KNOW what you are doing. ------------
"""
#Import modules

import subprocess as sub
from time import sleep
import socket
import threading

sub.Popen(["midori", "-e", "Fullscreen"]) #open midori


#Check if internet is up
addr = (host, port) #the connection addr


while True:
    last = up #reset checking var
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #create socket
    try: #attempt to ping, change vars
        s.connect(addr)
        up = 1
        print "\n"
    except socket.error: #if error when pinging, change vars
        up = 0
        print "\n"

    print "LAST CHECK:", last
    print "CURRENT CHECK:", up
    if last == 0 and up == 1:
        print "Reloading Midori.\n"
        sub.call(["midori", "-e", "Reload"])
    s.close()


    sleep(recheck_time)
syb0rg
  • 8,188
  • 4
  • 37
  • 51
  • Thanks for the speedy response! This does the job, but it also opens a second, non-fullscreen Midori browser instance of my webpage. No big deal since it is under the Fullscreen instance I wanted but it would be nice to not have both running at the same time. – SugaredRiotPoof Aug 28 '13 at 14:02
  • I believe that I have edited in a fix. Try my new code. – syb0rg Aug 29 '13 at 14:55