Skip to content

Instantly share code, notes, and snippets.

@trisweb
Created May 3, 2012 17:01
Show Gist options
  • Save trisweb/2587249 to your computer and use it in GitHub Desktop.
Save trisweb/2587249 to your computer and use it in GitHub Desktop.
A wrapper for linux airfoilspeakers command to restart when it inevitably crashes.
#!/usr/bin/env ruby
# Ctrl-C
Signal.trap 'INT' do
puts "Exiting!"
exit(0)
end
puts "Starting Airfoil Speakers..."
while 1
`airfoilspeakers`
error_code = !$?.success?
if error_code
puts "Trapped exit code #{$?}! Restarting..."
sleep(2)
else
break
end
end
puts "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment