wmiirc-rumai

git clone git://oldgit.suckless.org/wmiirc-rumai/
Log | Files | Refs | README | LICENSE

commit 59daad1c50c38c0fef9bc2daf1f878e441f86b82
parent 12086db40e2a7c528a03ed5990a79f065193d325
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date:   Sun, 27 Jan 2008 11:25:17 -0800

split status bar information into independent buttons

Diffstat:
wmiirc-config.rb | 49+++++++++++++++++++++++++++++--------------------
1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/wmiirc-config.rb b/wmiirc-config.rb @@ -176,33 +176,42 @@ EOF end end - action :status do - if defined? @status - @status.kill - end - - @status = Thread.new do - bar = fs.rbar.status - bar.create unless bar.exist? + class StatusBar < Thread + def initialize aBarNode, aRefreshRate, aBarColor = Color::NORMAL, &aBarText + raise ArgumentError unless block_given? - loop do - diskSpace = `df -h ~`.split[-3..-1].join(' ') - cpuLoad = File.read('/proc/loadavg').split[0..2].join(' ') + super aBarNode do |b| + b.create unless b.exist? - 5.times do - bar.write [ - Color::NORMAL, - Time.now, - cpuLoad, - diskSpace, - ].join(' | ') - - sleep 1 + while true + b.write "#{aBarColor} #{aBarText.call}" + sleep aRefreshRate end end end end + action :status do + if defined? @statusBars + @statusBars.each {|s| s.kill } + end + + @statusBars = [ + StatusBar.new(fs.rbar.clock, 1) do + Time.now + end, + + StatusBar.new(fs.rbar.cpu_load, 5) do + File.read('/proc/loadavg').split[0..2].join(' ') + end, + + StatusBar.new(fs.rbar.disk_space, 10) do + rem, use, dir = `df -h ~`.split[-3..-1] + "#{dir} #{use} used #{rem} free" + end, + ] + end + # Key bindings