Skip to content

Instantly share code, notes, and snippets.

@kdwinter
Created February 19, 2009 12:15
Show Gist options
  • Save kdwinter/66892 to your computer and use it in GitHub Desktop.
Save kdwinter/66892 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'procfile_parser'
module Moc
def self.run
moc = ProcFile.new(IO.popen("mocp --info"))[0]
@state = { :play => :playing, :pause => :paused, :stop => :stopped }[moc["State"].downcase.to_sym]
@file = moc["File"]
@title = moc["Title"]
@artist = moc["Artist"]
@song_title = moc["SongTitle"]
@album = moc["Album"]
@total_time = moc["TotalTime"]
@time_left = moc["TimeLeft"]
@total_sec = moc["TotalSec"].to_i
@current_time = moc["CurrentTime"]
@current_sec = moc["CurrentSec"].to_i
@bitrate = moc["Bitrate"]
@rate = moc["Rate"]
@title
end
end
puts Moc::run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment