Skip to content

Instantly share code, notes, and snippets.

@xoebus
Created April 11, 2011 20:01
Show Gist options
  • Save xoebus/914205 to your computer and use it in GitHub Desktop.
Save xoebus/914205 to your computer and use it in GitHub Desktop.
def flash_running?
begin
`ps aux`.split("\n").find { |process| process.include? "Flash" }.match(/\w+\s*\d+\s*([\d.]+)\s*.*/)[1].to_i > 4
rescue NoMethodError
false
end
end
def sample
results = []
5.times do
results << flash_running?
sleep 1
end
if results.count(true) > 4
puts "Flash is playing..."
true
else
puts "Flash is not playing..."
false
end
end
loop do
unless sample
puts "Playing if we aren't playing..."
`osascript -e "tell application \\"iTunes\\" to play"`
end
sleep 20
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment