I needed to update the "player" that we've been using to display our digital signs. I had originally had the idea that I would shut the machines down at night and have them start up in the morning, but that never worked reliably. I don't know if its because I had them set to "wake on lan" or to restart automatically after a power outtage but, whatever the reason, they haven't been going off at night. So that needed to get fixed.
Up until now, each client has had the firefox homepage set to something with a unique file in radmind. Clunky, but not difficult when you only have two signs. CNS wants to use our player image and they are going to have a plethora of signs. So we needed a way that all the clients could be the same.
I also learned that the CNS signs, which are going to use our player, needed some additional features, so I rolled them into the project. In particular, they needed a different browser (due to bugs in Firefox 3.6) and to have the system be able to display a different set of content at night.
I found that you seemingly can't script powering off the display, but I did find a little binary that turns the screen off. And to automate how the system knows what content to display, I decided to write a little script.
It took me longer to get working than I would have liked, but it works pretty well. It's a little script that looks up a flle on our server to figure out the URL that our digital signs are supposed to display, and then starts up Firefox 4 in full-screen mode. And hides the cursor. Someday, I'll learn to document my code.
#! /usr/bin/php
<?
date_default_timezone_set('America/New_York');
$name=`hostname`;
$name = rtrim($name);
$m = date(a);
$settings = `curl -s http://bcrc.bio.umass.edu/signs/${name}-${m}.txt`;
$url = rtrim($settings);
if(preg_match("/^http/", $url)) {
exec("killall firefox-bin");
sleep(1);
system("open /Applications/Firefox.app --args ${url}");
system("osascript -e 'tell application \"Firefox\" to activate'");
sleep(1);
system("osascript -e 'tell application \"System Events\" to keystroke \"f\" using {command down, shift down}'");
system("osascript -e 'tell application \"System Events\" to keystroke \" \"'");
}
else {
system("/usr/local/bin/displaysleep");
}
?>
I was thinking about having the file contain multiple settings, rather than just the URL. But so far it's just the URL.
- Steven D. Brewer's blog
- Log in to post comments