From within a ruby script, what is the best way to check if a Mac OS X app is currently running or not? I’m looking for something equivalent to this AppleScript:
if appIsRunning("iChat") then
...
end if
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning
(but I don’t want to use AppleScript, because it’s a tad slow)
There are probably better answers, but one simple way is to do this:
Doing this on my system (OSX Lion, Ruby 1.9.2-p290):