Decoupled Icecast Streaming

November 23, 2003

I separated the Icecast streaming for Pablotron Radio from XMMS. I'm just using shout to queue files for the stream now. I also wrote a brief script which calls XOSD to notify me when a new song comes on. Here's the script:

#!/usr/bin/env ruby

# some XOSD settings
ENV['DISPLAY'] = ':0'
FONT = "-adobe-helvetica-bold-r-normal-*-20-*-*-*-p-*-iso8859-2"

# fork and exit so shout doesn't block
pid = fork
if pid
  Process::waitpid(pid, Process::WNOHANG)
  exit 0
end

# make sure the cue file updates
sleep 1

# read the cue file and pipe it to xosd
File::open('/var/log/icecast/.cue', 'r') { |cue|
    name, size, rate, time, unknown, ofs = cue.readlines.map { |i| i.chomp }
  IO::popen("osd_cat -p bottom -f #{FONT} -s 1 -c \\#ffcc00", 'w') { |osd|
    osd.puts "#{time} - #{name}"
  }
}

Why go through all this trouble? So I can use XMMS to search for and preview songs locally, without messing with the active stream. Plus it's neat to have XOSD notifications for stuff :).