For anyone who wants it, you can add these two lines:
exec("osascript -e 'tell application \"System Events\" to set visible of process \"$app\" to true'");
exec("osascript -e 'tell application \"System Events\" to set frontmost of process \"$app\" to true'");
to
function startapp($app) {
exec("osascript -e 'tell application \"$app\" to launch'",$response);
if (isrunning($app) == "1")
return "$app launched";
else
return "Error launching $app";
}
between return "Error launching $app"; and the bracket to make the application you launch come to the front.
(it's in functions.php)
I wrote a script to generate HTML for the application launcher. It isn't great, but it works.
See it at: https://github.com/kuyanata...
Just for anyone who might be able to use it.
Cool! My only concern would be that when you load the page from your server, by default it checks every process in the list to determine if it's running. Because it's doing that with AppleScript, the thread/memory control is pretty bad and a long list could probably hang the server… I haven't tried it, though… how long a list have you been able to load?
It wouldn't be too difficult to remove the check for initial state and just check an app when it's requested. For example, don't have the switch show up when the page loads, tap the app name to check it's state, then get the switch set to the correct on/off state for toggling. That would circumvent the whole issue, and you could run your entire Apps folder out of it.
I've been able to load a list of about 54 applications. There /is/ a bit of lag when I go to the page, but not that much.
I agree with your solution. As an alternative. you could remove the switches and just have a button that performs the same function.
Oh, and I found out if an application's name takes up too much space, then the on/off switches will be pushed down, pushing some of the switches below it with it.
Hi,
I installed the homecontrol scripts on my webserver and the page loads fine. the first time I went to the application section it figured out that sendtome was started but did not recognize itunes running. since then it does not recognise any app being launched . whenever i turn any app on, it says "error loading itunes" on the info bar.
i have got php5 installed.
any idea?
I'm getting the same thing as Jeff!
I just got a screenshot from Jeff, and it appears to be a permissions problem with writing the volume out to a text file, at least in part. In Terminal, change to the folder where homecontrol lives (cd ~/Sites/homecontrol) and then type
touch volume.txt; chmod 777 volume.txt
See if that helps, and let me know.
I cannot seem to get the web app working. Every time a function is called, I get errors regarding a parameter needing to be a resource, but given as a boolean. This is true of the volume commands and app launching commands. The iTunes commands don't seem to do much of anything. I have my personal web server up and running with PHP5 installed. Any ideas?
It looks like you may be missing a few images from the zip file. I'm getting a few 404's while things are running. I'm adding support for toggling Airfoil speakers. Let me know if you're interested in my (very hacky) code!
I'll take a look at the zip and see what's up. I'd definitely love to see what you do with the Airfoil toggle. Feel free to contact me with an update!
Wow, this looks very cool! I have just been on a parallel path the last week or so, actually, and came up with this : http://code.google.com/p/bu...
Your web development skills are much better then mine, I see :-)
I also started off with PHP and apache, but moved over to using Python and the Tornado web server package (http://www.tornadoweb.org/). Using Platypus ( http://www.sveinbjorn.org/p..., I was able to make a user launchable web-server app with custom password and port.
Can't wait to look at your stuff this evening!