class Barr::Blocks::Rhythmbox
Attributes
view_opts[R]
Public Class Methods
new(opts = {})
click to toggle source
Calls superclass method
Barr::Block::new
# File lib/barr/blocks/rhythmbox.rb, line 8 def initialize(opts = {}) super reassign_deprecated_option opts, :show_artist, :artist reassign_deprecated_option opts, :show_title, :title reassign_deprecated_option opts, :show_buttons, :buttons @view_opts = { artist: opts[:artist].nil? || opts[:artist], buttons: opts[:buttons].nil? || opts[:buttons], title: opts[:title].nil? || opts[:title] } end
Public Instance Methods
running?()
click to toggle source
# File lib/barr/blocks/rhythmbox.rb, line 46 def running? `pgrep rhythmbox`.chomp.length != 0 end
update!()
click to toggle source
# File lib/barr/blocks/rhythmbox.rb, line 21 def update! op = [] if @view_opts[:artist] || @view_opts[:title] if(running?) info = sys_cmd.split(' - ') if @view_opts[:artist] && @view_opts[:title] op << info.join(' - ') elsif @view_opts[:artist] op << info[0] elsif @view_opts[:title] op << info[1] end else op << 'None' end end op << buttons if @view_opts[:buttons] @output = op.join(' ') end
Private Instance Methods
sys_cmd()
click to toggle source
# File lib/barr/blocks/rhythmbox.rb, line 60 def sys_cmd `rhythmbox-client --print-playing`.chomp end