class Barr::Blocks::Conky
Attributes
text[R]
Public Class Methods
new(opts={})
click to toggle source
Calls superclass method
Barr::Block::new
# File lib/barr/blocks/conky.rb, line 8 def initialize opts={} super @text = opts[:text] write_template spawn_conky end
Public Instance Methods
destroy!()
click to toggle source
# File lib/barr/blocks/conky.rb, line 47 def destroy! `rm #{@filename_template}` `rm #{@filename_output}` end
spawn_conky()
click to toggle source
# File lib/barr/blocks/conky.rb, line 42 def spawn_conky @process = spawn("conky -c #{@filename_template} > #{@filename_output}") Process.detach(@process) end
sys_cmd()
click to toggle source
# File lib/barr/blocks/conky.rb, line 20 def sys_cmd `tail -n1 #{@filename_output}`.chomp.gsub("#","\u2588") end
update!()
click to toggle source
# File lib/barr/blocks/conky.rb, line 16 def update! @output = sys_cmd end
write_template()
click to toggle source
# File lib/barr/blocks/conky.rb, line 24 def write_template @conky_template = " out_to_x no out_to_console yes own_window no update_interval #{@interval.to_f.to_s} TEXT #{@text} ".gsub(/^\s+/, '').chomp! @filename_template = tmp_filename+"-conky" @filename_output = tmp_filename+"-output" STDERR.puts "@conky_template: " STDERR.puts @conky_template File.open(@filename_template, "w") { |f| f.write(@conky_template) } end