eigenclass logo
MAIN  Index  Search  Changes  PageRank  Login

ruby-wmii community: plugins and configurations

(page temporarily locked due to spam)

Plugins

Yes, some people actually use ruby-wmii and have written plugins for it :-) Several applets in the standard distribution were contributed by others, but there are a few other external resources you might find of interest:

Configuration

you can share your snippets here

Intelligent client retagging

A note about client retagging: it's been pointed out to me that the 'rules' at the start of the wmiirc-config.rb can be used as an easier method of autotagging. I had not realized this, and I guess the only advantage to using my example is if for some reason you want a little more control, as with the way I title my terminal windows and then tag them by parts of their titles by looking at /client/n/name. I don't know if 'rules' looks at /client/n/class or name, though...

I messed around with wmiirc-config.rb to get it to auto-tag some of my clients (like the default browser-tagged-as-web bit). I wrote about it here: on my blog, but here's the code snip:

  # these are tags for particular apps that I want to have 
  # new tags - note, they won't get appended to their current tag

  tag_for_apps = { 
    "irc" => "Xchat", 
    "gaim" => "Gaim", 
    "web" => "Firefox",
    "4-jedit" => "jedit"
  }
  
  # these are terminals that I've given specific titles to
  # so they can be tagged
  tag_for_named_terms = {
    "2-consoles" => "console:",
    "3-logs" => "log:",
    "1-terms" => "term:"
  }
    
  # now when a new client comes up, check for an autotag
  on_createclient do |cid|
    LOGGER.info "checking for autotag on class: #{read("/client/#{cid}/class")} " + 
        "and name: #{read("/client/#{cid}/name")} "
    # if this client is a terminal, check the 'name'
    if /terminal/ =~ read("/client/#{cid}/class")
      tag_for_named_terms.each do |tfn|
        names_re = /#{tfn[1]}/
        if names_re =~ read("/client/#{cid}/name")
          write("/client/#{cid}/tags", tfn[0])
          LOGGER.info "  ... autotag'd #{tfn[1]} with #{tfn[0]}!"
        end
      end
    # not a terminal, so go by the 'class'
    else
      tag_for_apps.each do |tfa|
        apps_re = /#{tfa[1]}/
        if apps_re =~ read("/client/#{cid}/class")
          write("/client/#{cid}/tags", tfa[0])
          LOGGER.info "  ... autotag'd #{tfa[1]} with #{tfa[0]}!"
        end
      end
    end
  end
# ... rest of wmiirc-config.rb

As I mentioned in my blog post, I wonder if this would be a candidate for a plugin. I had a tough time figuring out how to go about setting it up as a plugin, however, so I'd love to hear any hints.

- Jason L

Fast switching (frame zooming) between max and default modes

When I want more space in terminal frame for scrollback, I press MODKEY-h. It's very simple, but I missed this feature somehow.

In my eo-plugins.rb file:

 binding("toggle-view", "MODKEY-h") do |wmii, keyhandler|
   mode = case wmii.read("/view/sel/mode")
          when "default" then "max"
          when "max" then "default"
          when "stack" then "default"
          end
   wmii.write("/view/sel/mode", mode)

- <xeox at xaoizorax xorgx> (Remove all x's, please.)

Tagging new windows from the shell

Ctrl-Alt-y works well for starting new apps from wmiimenu, but sometimes you want or need to start something from a shell prompt. Here's a simple hack to do that:

To wmiirc-config.rb, add:

  # Hack to tag "next" window from shell or elsewhere
  @nexttag = ""
  register("NextWindowTags", nil, nil) {|tag,| @nexttag = tag }
  on_createclient do |cid|
     if @nexttag != ""
        write("/client/#{cid}/tags", @nexttag )
        @nexttag = ""
     end
  end

To your .bashrc or equivalent, add:

  function on () {
     TAG=$1
     shift
     echo "NextWindowTags $TAG" | wmiir write /event
     $*
  }

Reload your wmiirc, and source the bash function, and you should now be able to automatically tag new windows from the shell. For example:

  $ on email xterm -e mutt &
  $ on irc xterm -e irssi &
  $ on code+work vim /path/to/some/code.c &

- Dave O'Neill (<dmo@dmo.ca>)