假设您的系统上装有Python,则可以使用的替代方法cron
。我创建了一个快速的Python 2.7.3脚本,它将每5分钟重新加载一次Midori。
#This program reloads midori every 5 minutes
#Redifine the variables below as you see fit
rest_time = 300 #Rest time is set to 300 seconds (5 minutes)
import subprocess as sub #Imports terminal commands (needed for reload)
from time import sleep #Import sleep (allows an infinite loop to become dormant)
while True: #This is an infinite loop. This means that our script won't stop.
sub.call(["midori", "-e", "Reload"]) #This forwards our command to the terminal
sleep(rest_time) #Wait rest_time second(s), then start the loop again.
如果您需要更改休息时间,只需更改rest_time
变量。
新剧本
正如您说的那样,您需要该程序“智能”,我对此进行了编辑。使用该程序时,请不要手动打开Midori。从脚本中打开它。如果您不这样做,我有一个习惯因速拨器而崩溃。它还可以在Python 2.7.3上运行。如果您不想全部复制和粘贴,请访问我的代码的pastebin。
"""
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", "-a", page_to_open_to]) #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)
qdbus
(从packagelibqt4-dbus
)或其他类似工具,然后在其中寻找Midori。然后,您很可能可以触发页面刷新。