wmii-3.1 configuration in Ruby

Suraj N. Kurapati


  1. Quick & light Ruby interface
    1. Interactive Ruby shell
      1. Logging and recovery
        1. Related works
          1. Screen shots
            1. A colorful mess
              1. Automated arrangements
                1. Multiple client selection
                2. Requirements
                  1. Ruby
                    1. wmii
                      1. Patches
                    2. Interactive live demonstration
                      1. Operations on multiple clients
                        1. Easy column manipulation
                          1. Automated client arrangement
                            1. Temporary working area
                            2. Installation

                              This article presents my patches to the wmii window manager and my Ruby-based configuration thereof. You can download wmii-3.1 with my patches pre-applied or clone it yourself from my GitHub repository:

                              git clone git://github.com/sunaku/wmii.git
                              

                              Quick & light Ruby interface

                              The ruby-ixp library is used to communicate directly with wmii’s IXP file system instead of the wmiir tool. Thus, wmii’s responsiveness is dramatically improved.

                              A light abstraction layer is built atop the ruby-ixp library to encapsulate access to wmii. This layer includes the ability to dynamically traverse the IXP file system by simply calling methods (thanks to Ruby’s method_missing facility). For instance, you can write “foo” into the file /view/sel/sel/tags via any of the following:

                              Wmii.current_client.tags = 'foo'
                              Wmii.fs.view.sel.sel.tags = 'foo'
                              Ixp::Client.write '/view/sel/sel/tags', 'foo'
                              

                              Interactive Ruby shell

                              The wmiish tool can be used to interact with wmii without having to install my wmiirc. It presents the previously discussed light abstraction layer within a standard IRB session. In fact, it even accepts the standard IRB command-line options!

                              Logging and recovery

                              Unhandled exceptions are logged to ~/.wmii-3/wmiirc.log and then reported to the user, who can then choose to recover from or fix the error. Thus, you won’t be left helpless if your configuration breaks.

                              Related works

                              ruby-wmii is Mauricio Fernandez’s popular Ruby-based configuration for wmii. It is very sophisticated and extensible, through a nice plugin interface.

                              Screen shots

                              As they say, “a picture is worth a thousand words”. So whet your appetite with these screen shots before diving into the discussion below. But don’t forget that you’ll be trying these out yourself shortly, in the interactive live demonstration!

                              A colorful mess

                              I first made a mess, colored generously for aesthetics, in my view by executing for c in red green blue black orange brown gray navy gold; do xterm -bg $c -title $c -e read & done in my shell. Then, I started up wmiish to demonstrate some of the stuff discussed below.

                              An empty desktop.The first inhabitant.A colorful desktop.

                              Automated arrangements

                              The tile arrangement, caused by the current_view.tile! command:

                              current_view.tile!

                              The grid arrangement, caused by the current_view.grid! command:

                              current_view.grid!

                              The diamond arrangement, caused by the current_view.diamond! command:

                              current_view.diamond!

                              Multiple client selection

                              Here I reorganized the view to give enough space for the terminal by typing the following code.

                              # apply tiling arrangement
                              current_view.tile!
                              
                              # set second column to stacking mode
                              current_view[2].mode = :stack
                              
                              Back to the drawing board.

                              Next I selected the three primary colored clients (NOTE: I normally do this by right-clicking on their title bars or through other shortcuts, because that’s how my wmiirc‘s event loop is configured) by typing the following code. Notice that those clients also appear in the “SEL” view.

                              # the primary colors
                              colors = %w[ red green blue ]
                              
                              # select clients named after the primary colors
                              clients.each do |c|
                                if colors.include? c.name
                                  c.select!
                                end
                              end
                              
                              A selection of primary colors.

                              Finally I put each client in the selection into its own view by typing the following code.

                              # tag each selected client with its own name
                              selected_clients.each do |c|
                                c.tag! c.name
                              end
                              
                              Tagging the selection.

                              Requirements

                              Ruby

                              You need at least version 1.8 of Ruby installed.

                              wmii

                              Apply this giant patch, which includes all of my patches, before compiling and installing wmii-3.1. Note that if you’re only interested in trying wmiish, then only the “unique client ID numbers in file system” patch is necessary.

                              $ ls
                              wmii-3.1.patch wmii-3.1.tar.gz
                              
                              $ tar zxf wmii-3.1.tar.gz
                              
                              $ patch -p0 < wmii-3.1.patch
                              patching file wmii-3.1/cmd/wm/area.c
                              patching file wmii-3.1/cmd/wm/client.c
                              patching file wmii-3.1/cmd/wm/fs.c
                              patching file wmii-3.1/cmd/wm/wm.h
                              
                              $ cd wmii-3.1
                              
                              $ make install
                              

                              Patches

                              Interactive live demonstration

                              Once you’ve satisfied the requirements, you can try this demonstration (in real-time!) using wmiish. Also, have a look at the provided documentation for available commands and my wmiirc configuration for more examples to try.

                              Operations on multiple clients

                              You can select multiple clients and perform operations on them. This is useful when you want to do something with a group of clients but don’t want to manually focus one, perform the action, focus the next one, and so on.

                              Another important aspect is that selected clients stay selected until they are unselected. This allows you to continue performing tasks on the selection without having to reselect the same clients after every operation.

                              For example, try executing the following commands in wmiish.

                              current_view.select! current_area.unselect! selected_clients.each {|c| c.tag! 'foo'}
                              
                              current_view.invert_selection! selected_clients.each {|c| c.tag! 'qux'}
                              current_view.invert_selection!
                              

                              Easy column manipulation

                              You can insert a group of clients to the top, bottom, or after the currently focused client of any column using these simple methods.

                              For example, try executing the following commands in wmiish.

                              current_view[0].concat! current_area
                              
                              current_view[3].unshift! current_view[1].clients[1..2]
                              

                              Automated client arrangement

                              You can arrange all clients in the current view using these automated arrangements. They help you maintain clean, uncluttered, usable views.

                              For example, try executing the following commands in wmiish.

                              current_view.tile!
                              
                              current_view.grid!
                              
                              current_view.diamond!
                              
                              current_view.grid! 1
                              
                              current_view.grid! 3
                              
                              current_view.grid! 0
                              

                              Temporary working area

                              You can send selected clients to a temporary working area (see the rationale and use case for this idea) and bring them back again when you’re finished. Try this by executing toggle_temp_view in wmiish.

                              Installation

                              1. Download and extract the contents of the package into your ~/.wmii-3 directory.

                              2. Edit the ~/.wmii-3/wmiirc-config.rb file to accomodate your needs.

                              3. Reboot wmii.


                              Updates