Linux Box Admin
Trusted Remote Administration
logo

Tilde
What's new
Articles
Micro HowTos
About
Contact



Fresh Micros




Tiling Window Management with Fvwm
(1 vote)
Tuesday, 10 July 2007
   
    Tiling Window Management with Fvwm    
     
       
 

Why
 
If you have 10+ GUI applications running and spend lots of time dragging them to the right place, you need a tiling window manager. On contrary to most modern window systems, which allow you to put one window on top of another, and mess up your work space, a tiling window manager will arrange all your windows tiling around your work space, with no extra space wasted, and no window overlap. Tiling window managers are good for people who cares more about efficiency, on both time and screen space assets. The most famous tiling window managers are ion_ and wmii_. However, when using a real tiling window manager like the two above, you lost some freedom: because all the windows are forced to be tiled around, it is hard to use some multi-window programs, like Gimp_. You can run another window manager inside ion_, but you'd quickly get lost between those two running window managers. Also the above two both have efficiency and low footprint in mind when building, so they are not as flexible and there's not too much options you can customized and not too much fancy features. Today we'll emulate the most part of a tiling window manager with Fvwm_, without losing any flexible and/or fancy stuffs like a transparent menu system. .. _ion: http://modeemi.fi/~tuomov/ion/ .. _wmii: http://www.suckless.org/wiki/wmii/ .. _Gimp: http://www.gimp.org .. _Fvwm: http://www.fvwm.org

 

 

The target

We' divide our screen to totally 16 (4x4) blocks, and the goal is to make any window resize to 1, 2, 3, 4, 6, 8, 9, 12, or 16 blocks with some simple key strokes, and place it at the upper left corner of any of these 16 blocks. And instead of assuming you are using a 1024x768 screen in my `previous article`_, we'll make it fit no matter what the screen resolution is. .. _previous article: quake_like_terminal_with_Fvwm.html

 

 

What we need

We won't need too much Fvwm_ commands for this: Maximize This is the command we'll use to resize our windows. If it is called without any argument, the current window will be toggled between a **maximize** and a **normal** status. If we want to force it to **maximize**, we add a *True* argument, if we want to force it **normal**, we pass a *False*. And if we add two numbers after that, it will be the percentage of the screen size, horizontal and vertical, accordingly. For example, if we want to resize a window to hold three blocks horizontal, and 1 block vertical, we use:: Maximize True 75 25 Move We've talked about this in the `previous article`_. But unlike specify the absolute point there, we use relative numbers like the *Maximize* command above. The trick is easy: Just remove the post-fix **p**. So if we want to move the upper left corner of a window to the middle of the screen, we say:: Move 50 50 Popup This will pop up a menu with the given name. Very useful when we want a cascading menu system. OK, so here's pretty much all what we need. Easy?

 

 

Yeal, show me the code!

OK, here's all the code:: DestroyMenu QuickWindowMenu AddToMenu QuickWindowMenu + "&Size" Popup size_menu + "&Place" Popup Place_menu DestroyMenu size_menu AddToMenu size_menu + "&Small" Popup Small_menu + "&Half" Popup Half_menu + "&Big" Popup Big_menu + "&Quarter" Maximize True 50 50 DestroyMenu Half_menu AddToMenu Half_menu + "Half&Big" Popup Half_Big_menu + "Half&Horizont" Maximize True 50 100 + "Half&Quarter" Maximize True 50 25 + "Half&Small" Popup Half_Small_menu + "Half&Vertical" Maximize True 1024p 50 DestroyMenu Big_menu AddToMenu Big_menu + "Big&Big" Maximize True 75 75 + "Big&Horizont" Maximize True 75 100 + "Big&Small" Popup Big_Small_menu + "Big&Vertical" Maximize True 100 75 DestroyMenu Small_menu AddToMenu Small_menu + "Small&Big" Popup Small_Big_menu + "Small&Horizont" Maximize True 25 100 + "Small&Small" Maximize True 25 25 + "Small&Vertical" Maximize True 100 25 # sub-sub menu DestroyMenu Big_Big_menu AddToMenu Big_Big_menu + "BigBig&Horizont" Maximize True 75 75 + "BigBig&Vertical" Maximize True 75 75 DestroyMenu Big_Small_menu AddToMenu Big_Small_menu + "BigSmall&Horizont" Maximize True 25 75 + "BigSmall&Vertical" Maximize True 75 25 DestroyMenu Place_menu AddToMenu Place_menu + "&1" Move 0 0 + "&2" Move 50 0 + "&3" Move 0 25 + "&4" Move 50 25 + "&5" Move 0 50 + "&6" Move 50 50 + "&7" Move 0 75 + "&8" Move 50 75 + "" Nop + "&Right" Popup Place_Right_menu DestroyMenu Place_Right_menu AddToMenu Place_Right_menu + "&1" Move 25 0 + "&2" Move 75 0 + "&3" Move 25 25 + "&4" Move 75 25 + "&5" Move 25 50 + "&6" Move 75 50 + "&7" Move 25 75 + "&8" Move 75 75 Get the idea? I use **Small**, **Big**, **Half**, and **Horizont**, **Vertical**, **Quarter** to name how to separate the 16 blocks here. Two more thing: The *&* creates a shortcut key for the menu item, and the *+ "" Nop* line makes a separator line in the menu. Now all you need is binding the function *QuickWindowMenu* to some key stroke or mouse click on a window. And as this has been talked in our `previous article`_, this is left for you as an exercise :)

 

dryice at dryice dot name
This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

 

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License.
   
       
         
 

Copyright © 2006,2007 Linux Box Admin.

 
My NHL fan blog