Permalink
Fetching contributors…
Cannot retrieve contributors at this time
316 lines (228 sloc) 10.6 KB
== USAGE
Now that you know how to start the interactive shell (see **DESCRIPTION**
above) let us walk through a series of examples that highlight the main
features of Rumai. You can follow along by copying & pasting the presented
commands into the interactive shell.
%|open_terms = lambda do
Launch a few terminals so that we have something to work with:
[source,ruby]
----------------------------------------------------------------------------
colors = %w[ red green blue black orange brown gray navy gold ]
colors.each {|c| system "xterm -bg #{c} -title #{c} -e sh -c read &" }
----------------------------------------------------------------------------
%|close_terms = lambda do
Close the terminals we launched earlier:
[source,ruby]
----------------------------------------------------------------------------
terms = curr_view.clients.select {|c| colors.include? c.label.read }
terms.each {|c| c.kill }
----------------------------------------------------------------------------
=== Automated client arrangement
% open_terms.call
Arrange all clients in a grid:
[source,ruby]
------------------------------------------------------------------------------
curr_view.arrange_in_grid
------------------------------------------------------------------------------
Arrange all clients in a diamond shape:
[source,ruby]
------------------------------------------------------------------------------
curr_view.arrange_in_diamond
------------------------------------------------------------------------------
Arrange all clients like LarsWM does:
[source,ruby]
------------------------------------------------------------------------------
curr_view.arrange_as_larswm
------------------------------------------------------------------------------
% close_terms.call
=== Multiple client grouping
% open_terms.call
Add the red, green, and blue terminals into the "grouping":
[source,ruby]
------------------------------------------------------------------------------
terms = curr_view.clients.select do |c|
%%w[red green blue].include? c.label.read
end
terms.each {|c| c.group }
------------------------------------------------------------------------------
You should now see a new button labelled as "@" on the left-hand side of
wmii's bar, indicating that there is now a new view labelled "@" in wmii.
Let us inspect what clients this mysterious view contains:
[source,ruby]
------------------------------------------------------------------------------
v = View.new "@"
puts v.clients.map {|c| c.label.read }
------------------------------------------------------------------------------
Aha! The mysterious view contains the red, green, and blue clients we
recently "grouped". Thus, by adding a client to the "grouping", we are
simply tagging the client with the "@" token.
Now that we have put some clients into the "grouping", let us move all
clients in the grouping to the floating area in the current view:
[source,ruby]
------------------------------------------------------------------------------
grouping.each {|c| c.send "toggle" }
------------------------------------------------------------------------------
Neat! Let us bring them back into the managed area:
[source,ruby]
------------------------------------------------------------------------------
grouping.each {|c| c.send "toggle" }
------------------------------------------------------------------------------
% close_terms.call
In summary, you can select multiple clients (by adding them to the
"grouping") and perform operations on them. This is useful when you want
to do something with a group of clients but do not 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.
=== Easy column manipulation
% open_terms.call
You can insert a group of clients to the top, bottom, or after the
currently focused client of _any_ column using Array-like methods.
Give each client its own column (one client per column):
[source,ruby]
------------------------------------------------------------------------------
curr_view.each_column {|c| c.length = 1 }
------------------------------------------------------------------------------
Put (at most) three clients in every column:
[source,ruby]
------------------------------------------------------------------------------
curr_view.each_column {|c| c.length = 3 }
------------------------------------------------------------------------------
Move the red, green, and blue clients into the floating area:
[source,ruby]
------------------------------------------------------------------------------
rgb = %w[red green blue]
terms = curr_view.clients.select {|c| rgb.include? c.label.read }
curr_view.areas[0].push *terms
------------------------------------------------------------------------------
Slurp all floating clients into the last column:
[source,ruby]
------------------------------------------------------------------------------
list = curr_view.areas
a, b = list.first, list.last
b.concat a
------------------------------------------------------------------------------
Set the last column's layout to stacking mode:
[source,ruby]
------------------------------------------------------------------------------
b.layout = 'stack'
------------------------------------------------------------------------------
Move the red, green, and blue clients to the top of the second column:
[source,ruby]
------------------------------------------------------------------------------
curr_view.areas[2].unshift *terms
------------------------------------------------------------------------------
Move the red, green, and blue clients to the bottom of the third column:
[source,ruby]
------------------------------------------------------------------------------
curr_view.areas[3].push *terms
------------------------------------------------------------------------------
% close_terms.call
=== Easy client manipulation
% open_terms.call
Obtain a reference to the red client:
[source,ruby]
------------------------------------------------------------------------------
red = curr_view.clients.find {|c| c.label.read == "red" }
------------------------------------------------------------------------------
Show the red client's current tags:
[source,ruby]
------------------------------------------------------------------------------
red.tags
------------------------------------------------------------------------------
Add the "foo" and "bar" tags to the red client:
[source,ruby]
------------------------------------------------------------------------------
red.tag "foo", "bar"
------------------------------------------------------------------------------
Remove the "bar" tag from the red client:
[source,ruby]
------------------------------------------------------------------------------
red.untag "bar"
------------------------------------------------------------------------------
Do complex operations on the red client's tags:
[source,ruby]
------------------------------------------------------------------------------
red.with_tags { concat %w[a b c]; push 'z'; delete 'c' }
------------------------------------------------------------------------------
Focus the next client after the red client:
[source,ruby]
------------------------------------------------------------------------------
red.next.focus
curr_client == red.next #=> true
------------------------------------------------------------------------------
Notice that by focusing a client, we make it the current client.
Focus the red client on a different view:
[source,ruby]
------------------------------------------------------------------------------
orig = curr_view
v = red.views.last
red.focus v
------------------------------------------------------------------------------
Return to the original view:
[source,ruby]
------------------------------------------------------------------------------
orig.focus
------------------------------------------------------------------------------
Send the red client to the last column:
[source,ruby]
------------------------------------------------------------------------------
red.send curr_view.areas.last
------------------------------------------------------------------------------
% close_terms.call
=== Traversing the file system
Show the root node of wmii's IXP file system:
[source,ruby]
------------------------------------------------------------------------------
fs
------------------------------------------------------------------------------
Show the names of all files at the root level:
[source,ruby]
------------------------------------------------------------------------------
fs.entries
------------------------------------------------------------------------------
Show the parent of the root node:
[source,ruby]
------------------------------------------------------------------------------
fs.parent
------------------------------------------------------------------------------
Show the children of the root node:
[source,ruby]
------------------------------------------------------------------------------
fs.children
------------------------------------------------------------------------------
Navigate into to the `/lbar/` directory:
[source,ruby]
------------------------------------------------------------------------------
n1 = fs.lbar
n2 = fs['lbar']
n1 == n2 #=> true
left_bar = n1
------------------------------------------------------------------------------
Notice that you can traverse the file system hierarchy by simply calling
methods on node objects. Alternatively, you can traverse by specifying an
arbitrary sub-path (relative path) using the `[]` operator on a node.
Create a new temporary button:
[source,ruby]
------------------------------------------------------------------------------
b = left_bar.rumai_example # path of new button
b.exist? #=> false
b.create
b.exist? #=> true
------------------------------------------------------------------------------
You should now see an empty button on the left-hand side of the wmii bar.
Color the button black-on-white and label it as "hello world":
[source,ruby]
------------------------------------------------------------------------------
content = "colors #000000 #ffffff #000000\nlabel hello world"
b.write content
b.read == content #=> true
------------------------------------------------------------------------------
Remove the temporary button:
[source,ruby]
------------------------------------------------------------------------------
b.remove
b.exist? #=> false
------------------------------------------------------------------------------