The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Scripting the wmii-3 window manager with Ruby

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eigen Class

Posts: 358
Nickname: eigenclass
Registered: Oct, 2005

Eigenclass is a hardcore Ruby blog.
Scripting the wmii-3 window manager with Ruby Posted: May 29, 2006 5:15 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Eigen Class.
Original Post: Scripting the wmii-3 window manager with Ruby
Feed Title: Eigenclass
Feed URL: http://feeds.feedburner.com/eigenclass
Feed Description: Ruby stuff --- trying to stay away from triviality.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Eigen Class
Latest Posts From Eigenclass

Advertisement

It's been over one week since the release of wmii-3, the dynamic window manager thats boasts

Wimp (Windows, Icons, Menus and Pointing device) is dead!

It took me one day to grow accustomed to the new tag-based workspaces, and a couple to stabilize my setup.

wmii ships with a few shell scripts that control the behavior of the WM: key bindings, menu bar, default options... I was more than willing to rewrite them in Ruby in order to get rid of that echo, sed, awk, etc. mess. In the process I abstracted things a little bit, making it easier to handle the events reported by the WM.

I can now define basic keybindings as follows:

  on_key("#{MODKEY}-#{LEFT}"){ write "/view/ctl", "select prev" }
  on_key("#{MODKEY}-#{RIGHT}"){ write "/view/ctl", "select next" }
  on_key("#{MODKEY}-#{DOWN}"){ write "/view/sel/ctl", "select next" }
  on_key("#{MODKEY}-#{UP}"){ write "/view/sel/ctl", "select prev" }

Other events are easily defined too. This is my "volume applet":

  on_barclick(volume_name, MOUSE_SCROLL_UP){ update_volume[+1] }
  on_barclick(volume_name, MOUSE_SCROLL_DOWN){ update_volume[-1] }

The good thing about using Ruby is that adding extra logic isn't a PITA, as it is in shell script, at least for me. The following snippet allows me to retag the current client partially, replacing only the numerical tag and leaving the other ones untouched:

  (0..9).each do |key|
    on_key("#{MODKEY}-Shift-#{key}") do
      oldtags = read("/view/sel/sel/tags").split(/\+/).reject{|x| /^\d+$/ =~ x}
      write "/view/sel/sel/tags", (oldtags + [key]).join("+")
    end
  end


Read more...

Read: Scripting the wmii-3 window manager with Ruby

Topic: If it's not nailed down ... Previous Topic   Next Topic Topic: Catching a train to RailsConf

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use