Created
November 20, 2012 01:56
-
-
Save dmytro/4115472 to your computer and use it in GitHub Desktop.
Low tech Mac music player
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 | |
def play songs | |
song = songs[rand songs.length].strip | |
puts song | |
song.gsub!('`','\\\\`') | |
$pid = Process.spawn "afplay -v .2 \"#{song}\"" | |
Process.wait $pid | |
sleep 1 | |
end | |
Kernel.trap('INT') { Process.kill "INT", $pid } | |
Kernel.trap('TSTP') { puts "Exiting..."; exit } | |
file = File.expand_path( ARGV[0] || "~/music.list") | |
songs = File.readlines(file) | |
play songs while true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment