The box needed to do only one task: start up, open a browser, cycle through links. Perfect job for applescript. The script to launch a browser and loop through links is simple:
#!/usr/bin/osascript
-- argv is a list of links to loop through
on run argv
tell application "Opera.app" to activate
tell application "System Events"
tell process "Opera"
click menu item "New Window" of menu "File" of menu bar 1
end tell
end tell
-- list of urls to cycle
repeat
repeat with someurl in argv
tell application "System Events" to set browserRunning to (name of processes) contains "Opera"
if browserRunning then
else
exit repeat
end if
tell application "Opera.app"
set URL of document 1 to someurl
delay 5
end tell
end repeat
tell application "System Events" to set browserRunning to (name of processes) contains "Opera"
if browserRunning then
else
exit repeat
end if
end repeat
end run
I made a python script that does everything else. Grabs a list of links from a feed, passes them over to the cycler:
#!/usr/bin/env python
import feedparser
import os
from subprocess import call
# this actually parses the feed as if it uses the firefox live bookmarks format
# your parsing may change on how your links are represented
applecmd = []
applecmd.append("osascript")
applecmd.append("kioskcycle.scpt")
d = feedparser.parse("http://myhost.com/somefeed.rss")
bookmarkitems = d['items']
for item in bookmarkitems:
for link in item.links:
applecmd.append(link.href)
os.chdir("/Users/someuser/Desktop")
call(applecmd)
And got it all working by turning my python script into a natively built python applet, and telling OSX to use it as a startup item. All pretty straight forward, under normal circumstances. Of course, my script initially used Safari, but things can never be that simple. RIT is its own Certification Authority, and Safari thinks some of RIT's sites (ie, my.rit.edu) are traps. Even if you forcefully allow the certificate to pass, Safari will warn you. This got on my nerves, so I went looking for another browser. Firefox dropped support for PPC a long time ago. Chrome never had it. TenFourFox, as nice as that is, doesn't work with applescript. I decided to settle on Opera 10, the last Opera release to work with PPC. It also gained Applescript support since 9.5. Nice.
I've got some major sanding, painting, drilling, and polishing to do tomorrow, so I'll be sure to post a picture of the final product of my labor. Mmmmm... power tools.
No comments:
Post a Comment