Created
May 3, 2012 17:01
-
-
Save trisweb/2587249 to your computer and use it in GitHub Desktop.
A wrapper for linux airfoilspeakers command to restart when it inevitably crashes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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