wmiirc-rumai

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

commit e42fe3e0197555a1e346f4d1f8d69e59ef90f754
parent 79fcaf78a8f4c981ff73c47cd5d26ad9a0603aa0
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date:   Wed, 13 May 2009 22:32:56 -0700

the order of status buttons now reflects their definition order

Diffstat:
config.rb | 6++++--
config.yaml | 121+++++++++++++++++++++++++++++++++++--------------------------------------------
2 files changed, 58 insertions(+), 69 deletions(-)

diff --git a/config.rb b/config.rb @@ -297,9 +297,11 @@ def load_config config_file unless defined? @status_button_by_name @status_button_by_name = {} - CONFIG['display']['status'].each do |name, defn| + CONFIG['display']['status'].each_with_index do |hash, position| + name, defn = hash.to_a.first + # buttons are displayed in the ASCII order of their IXP file names - file = [defn['position'], name].compact.join('-') + file = "#{position}-#{name}" button = eval( "Button.new(fs.rbar[#{file.inspect}], #{defn['refresh']}) { #{defn['content']} }", diff --git a/config.yaml b/config.yaml @@ -88,84 +88,71 @@ display: ## # Self-refreshing buttons on the status bar. # - # <IXP node basename>: - # position: <index of this button on the status bar> # (optional) - # refresh: <number of seconds to wait before refreshing the content> - # content: <Ruby code whose result is displayed as the content> + # - <button name>: + # refresh: <number of seconds to wait before refreshing the content> + # content: <Ruby code whose result is displayed as the content> # # You can refresh a particular status button in Ruby using: # - # status( "IXP node basename" ) + # status("your button name") + # + # The horizontal order in which these buttons appear on the status + # bar reflects the vertical order in which they are defined below. # status: - clock: - position: 5 - refresh: 5 - content: Time.now.to_s - - system_load: - position: 4 - refresh: 10 - content: | - load_averages = File.read('/proc/loadavg').split.first(3) - current_load = load_averages.first.to_f - - # visually indicate the intensity of system load - color = case - when current_load > 3.0 then CONFIG['display']['color']['error'] - when current_load > 1.5 then CONFIG['display']['color']['notice'] - end - - [color, *load_averages] - - disk_space: - position: 3 - refresh: 600 # 10 minutes - content: | - free, used, path = `df -h ~`.split.last(3) - [path, used, 'used', free, 'free'] - - volume: - position: 2 - refresh: 60 - content: | - ['volume', `amixer get Master`.scan(/\d+%/).first] - - music: - position: 1 - refresh: 15 - content: | - unless defined? @music - require 'rubygems' - gem 'librmpd', '~> 0.1' - require 'librmpd' - - @music = MPD.new - end + - music: + refresh: 15 + content: | + unless defined? @music + require 'rubygems' + gem 'librmpd', '~> 0.1' + require 'librmpd' + + @music = MPD.new + end - unless @music.connected? - @music.connect - end + unless @music.connected? + @music.connect + end - music_state = (@music.stopped? || @music.paused?) ? '(-)' : '(>)' + music_state = (@music.stopped? || @music.paused?) ? '(-)' : '(>)' - if song = @music.current_song - artist = song.artist - title = song.title || (f = song.file and File.basename(f)) - song_name = [artist, title].compact.join(': ') - end + if song = @music.current_song + artist = song.artist + title = song.title || (f = song.file and File.basename(f)) + song_name = [artist, title].compact.join(': ') + end - [music_state, song_name].compact + [music_state, song_name].compact + + - volume: + refresh: 60 + content: | + ['volume', `amixer get Master`.scan(/\d+%/).first] + + - disk_space: + refresh: 600 # 10 minutes + content: | + free, used, path = `df -h ~`.split.last(3) + [path, used, 'used', free, 'free'] + + - system_load: + refresh: 10 + content: | + load_averages = File.read('/proc/loadavg').split.first(3) + current_load = load_averages.first.to_f + + # visually indicate the intensity of system load + color = case + when current_load > 3.0 then CONFIG['display']['color']['error'] + when current_load > 1.5 then CONFIG['display']['color']['notice'] + end - # TODO: mouse events on this status button - click: - left: - middle: - right: + [color, *load_averages] - scroll: - up: - down: + - clock: + refresh: 5 + content: Time.now.to_s ##