Saturday, January 07, 2006

Positioning Firefox in FVWM Windowspace

Finally, I've figured out how to get FVWM to put the Firefox browser where I want it when I start up my system.

A little background. As you probably have figured out by now, I use FVWM as my Window Manager in Linux. It's endlessly configurable, and does exactly what I want it to, when I want it, independent of what someone else thinks should be the default behavior of by desktop.

And yet, ...

Some applications are easy to position on an X11 desktop. For example, open a shell window, and run this command:

$ xterm -geometry 80x25-0-0 &

You now have a terminal window in the lower right corner of your screen. It's 80 columns wide and 25 rows wide. If you'd try

$ xterm -geometry 80x25+100-50 &

the window would appear 100 pixels from the left edge of your screen and 50 pixels from the bottom.

The old Mozilla browsers used to obey this type of command, but neither Mozilla, Netscape, nor Firefox do anymore. This presents a problem. When I log on to this machine, I open and FVWM desktop which is 9 times bigger than my terminal screen. I'd like specific applications specific places when I log on. If you excuse my ASCII art, I'd like the thing to look like this:


|----------|----------|----------|
|       0,0|       1,0|       2,0|
| Evolution| Emacs    |          |
|          |          |          |
|----------|----------|----------|
|       0,1|       1,1|       1,2|
| Firefox  | Ical     |          |
|          |          |          |
|----------|----------|----------|
|       0,2|       1,2|       2,2|
|          |          |          |
|          |          |          |
|----------|----------|----------|

Where Evolution is my mail client, Emacs my editor, Firefox my browser, and Ical is a calendar program, though probably not the one you're thinking of. Each square, of course, represents a physical screen on the 3x3 virtual desktop. I can switch between them by scrolling the mouse past the edge of the screen.

Now Evolution starts at the first page of the virtual window, so I can just call it up in the usual manner. Emacs and Ical recognize the geometry command. I've got 1024x800 resolution on my screen, I can get these three programs to start up where I want them by adding this to my ~/.fvwm/.fvwm2rc file:

AddToFunc InitFunction
+ I Exec evolution &
+ I Exec emacs -fn 9x15 -geometry 81x42+1264+25 -T emacs &
+ I Exec ical -geometry +1024+800 &

But what about Firefox? If it respected the geometry option I could add another line:

+ I Exec firefox -geometry +0+800 &

But Firefox doesn't use -geometry. So what to do? For years I've brought up Firefox after I logged onto my system, insuring that it would go where I wanted it.

Today I found out about a FVWM command called StartsOnPage. It tells FVWM to start a certain "Style" of command on a specific page on your virtual desktop. See those little numbers in my desktop picture above? 2,2 is the lower right-hand screen, 1,0 the middle screen on the top, etc. I want to put Firefox in screen 0,1. This involves StartsOnPage, but I didn't know how. Then I found this post, which explains all, or at least enough for my purposes. What I need to do is make sure my ~/.fvwm/.fvwm2rc file has the lines:

Style Gecko StartsOnPage 0 1, SkipMapping

AddToFunc InitFunction
+ I Exec evolution &
+ I Exec emacs -fn 9x15 -geometry 81x42+1264+25 -T emacs &
+ I Exec ical -geometry +1024+800 &
+ I Exec firefox &

The "Gecko" style should work with Mozilla, Netscape, Galeon, ..., any Gecko-based browser, which includes Firefox. The "0 1" means start in window 0,1 on the above grid. I'm not sure what SkipMapping does, but it doesn't seem to hurt anything.

And now, when I log on, Firefox appears where I want it.

Finally.

0 comments: