[学习]FVWM-Introduction to FvwmButtons
FvwmButtons, also known as GoodStuff, is sometimes overlooked by new
fvwm users, despite being the most powerful software for creating
desktop panels available today.
I've written this guide to introduce FvwmButtons to new users, and
take anyone interested step by step through creating a simple panel.
Hopefully this will help get you started a little quicker than the man
page alone :).
This is the panel I am going to create.
http://dev.gentoo.org/~taviso/goodstuff1.png
It's very simple, has a set of nine buttons that can be bound to
applications or window controls. It also has an xclock along the top.
Of course, FvwmButtons has many, many features I havn't mentioned
here, but this should be enough to get started :)
Step 1: Planning
Fvwm uses a flat text based configuration, which is not an intuitive
method for designing user interfaces. The solution is to use a
graphics package to create a template to work from. You can use any
package you like, The GIMP, xpaint, dia, or even xfig.
Here is a screenshot of me planning this panel in dia..
http://dev.gentoo.org/~taviso/goodstuff2.png
As you can see I have an outline and the approximate layout of the
buttons all plotted in dia. Don't worry about this template being
perfect, we are just going to use it to estimate the dimensions in the
next step.
Step 2: Dimensions
Now that you have a template to work from, you can calculate what the
minimum grid size you will need in order to contain your buttons.
This is a lot simpler than it sounds, we just need to know how many
rows and columns we should split our panel into. Each button can take
up any whole number of grid squares, so we just have to make sure we
have enough.
http://dev.gentoo.org/~taviso/goodstuff3.png
As you can see, we need a minimum grid of 7 rows and 3 columns so that
each button occupies a whole number of grid squares. The top button
requires one row and 3 columns, the other buttons need 2 rows and 1
columns.
Step 3: Create Buttons
Now that we have the dimensions needed, we can make an absolute
minimum FvwmButtons configuration to test the dimensions.
You can tweak the button geometries and grid size until everything looks right.
代码:
DestroyModuleConfig LaunchTime: *
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: (3x1)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
As you can see, each configuration line for our panel starts with an
asterisk, then the panel alias. Lines that dont use brackets are
settings, lines that do are button definitons. The buttons defined
here only have one setting, how many rows and columns they need.
You can enter this in your fvwm2rc and restart, or paste it into an
FvwmConsole. I've used DestroyModuleConfig so that if you paste the
configuration into FvwmConsole twice, fvwm knows that you are not
trying to continue the same configuration.
Now lets try starting the panel, enter the following into your FvwmConsole
代码:
Module FvwmButtons -g 178x207 LaunchTime
The -g specifies the Geometry, it tells FvwmButtons how big you want
the panel to be (and also where you want it to appear).
Hopefully, you should see a window like this
http://dev.gentoo.org/~taviso/goodstuff4.png
Not very exciting yet, but don't worry, move on to the next step where
we will configure the buttons and add the bindings.
Step 4: Fill in the blanks
Swallowing is what FvwmButtons calls Reparenting, it basically means
any application window can be used as a button on your panel. So lets
use this concept to swallow an xclock into our new panel.
First lets find a command line for xclock that looks suitable for our panel.
代码:
xclock -bg '#31658c' -fg white -digital -face 'Aquafont:size=11'
-strftime '%a, %d %b %Y %H:%M'
This is what I have used. Now lets tell our panel how to start the clock.
代码:
*LaunchTime: (3x1, Swallow "xclock" `Exec xclock -bg '#31658c' -fg
white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y
%H:%M'`)
The first setting is the Rows and Columns we want, then the Swallow
command. the next argument is the name of the window FvwmButtons
should look out for, followed by the Fvwm command needed to start the
window.
Here is our new Panel:
代码:
DestroyModuleConfig LaunchTime: *
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: (3x1, Swallow "xclock" `Exec xclock -bg '#31658c' -fg
white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y
%H:%M'`)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
Enter the configuration into your FvwmConsole, and start the panel to
make sure everything has worked, hopefully you will see a window like
this:
http://dev.gentoo.org/~taviso/goodstuff5.png
Now for the next button, Let's make it a launcher for The GIMP.
代码:
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png)
As you can see, we have the dimensions, a Title and an Icon. All we
need now is to define an Action. Actions are responses to Clicks, so
lets say we want the first mouse button to start the gimp.
代码:
Action(Mouse 1) `Exec gimp`
Lets enter this into the button definition.
代码:
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png,
Action(Mouse 1) `Exec gimp`)
The configuration should now look like this:
代码:
DestroyModuleConfig LaunchTime: *
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: (3x1, Swallow "xclock" `Exec xclock -bg '#31658c' -fg
white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y
%H:%M'`)
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png,
Action(Mouse 1) `Exec gimp`)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
*LaunchTime: (1x2)
Test out the panel, if everything looks okay fill in the rest of the buttons.
代码:
DestroyModuleConfig LaunchTime: *
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: (3x1, Center, Swallow "xclock" `Exec xclock -bg '#31658c'
-fg white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y
%H:%M'`)
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png,
Action(Mouse 1) `Exec gimp`)
*LaunchTime: (1x2, Title "xmag", Icon telescope.png, Action(Mouse 1)
`Exec xmag`)
*LaunchTime: (1x2, Title "xcalc", Icon calculator.png, Action(Mouse 1)
`Exec xcalc`)
*LaunchTime: (1x2, Title "mozilla", Icon browser_ship-wheel.png,
Action(Mouse 1) `Exec mozilla`)
*LaunchTime: (1x2, Title "run", Icon gears.png, Action(Mouse 1) `Exec gmrun`)
*LaunchTime: (1x2, Title "gvim", Icon gvim.png, Action(Mouse 1) `Exec gvim`)
*LaunchTime: (1x2, Title "move", Icon hardware_mouse.png, Action(Mouse
1) `Pick Move`)
*LaunchTime: (1x2, Title "close", Icon bomb.png, Action(Mouse 1) `Pick Close`)
*LaunchTime: (1x2, Title "shade", Icon window.png, Action(Mouse 1)
`Pick WindowShade True`)
Start the panel and you should see something like:
http://dev.gentoo.org/~taviso/goodstuff6.png
Step 5: Finalise Panel
Test all your buttons, make sure everything is working, Hopefully it
is and you can setup Colorsets, Fonts, Frames, Padding and any other
setting you want!
代码:
Colorset 30 fg black, bg #c6c3c6, RootTransparent buffer, Tint #efebef 65
DestroyModuleConfig LaunchTime: *
*LaunchTime: Rows 7
*LaunchTime: Columns 3
*LaunchTime: Font "xft:Bitstream Vera Sans Mono:style=Roman:size=8"
*LaunchTime: Colorset 30
*LaunchTime: Frame 1
*LaunchTime: (3x1, Center, Swallow "xclock" `Exec xclock -bg '#31658c'
-fg white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y
%H:%M'`)
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png,
Action(Mouse 1) `Exec gimp`)
*LaunchTime: (1x2, Title "xmag", Icon telescope.png, Action(Mouse 1)
`Exec xmag`)
*LaunchTime: (1x2, Title "xcalc", Icon calculator.png, Action(Mouse 1)
`Exec xcalc`)
*LaunchTime: (1x2, Title "mozilla", Icon browser_ship-wheel.png,
Action(Mouse 1) `Exec mozilla`)
*LaunchTime: (1x2, Title "run", Icon gears.png, Action(Mouse 1) `Exec gmrun`)
*LaunchTime: (1x2, Title "gvim", Icon gvim.png, Action(Mouse 1) `Exec
"gvim" gvim`)
*LaunchTime: (1x2, Title "move", Icon hardware_mouse.png, Action(Mouse
1) `Pick Move`)
*LaunchTime: (1x2, Title "close", Icon bomb.png, Action(Mouse 1) `Pick Close`)
*LaunchTime: (1x2, Title "shade", Icon window.png, Action(Mouse 1)
`Pick WindowShade True`)
Try out the new Panel!
代码:
Module FvwmButtons -g 178x207 LaunchTime
Hopefully you should see something similar to this:
http://dev.gentoo.org/~taviso/goodstuff7.png
Now all you have to do is set any Style options you want, and decide
how to start your panel. Did you notice the extra argument to Exec on
the gvim button? Try pressing it, notice the button will stay down
until a window called gvim appears! You can do this for all the
buttons, if you like it.
Maybe you would like LaunchTime to always be visible?
代码:
Style LaunchTime StaysOnTop
And lets start it everytime we login
代码:
AddToFunc StartFunction
+ I Module FvwmButtons -g 178x207 LaunchTime
And finally, lets add it to a menu:
代码:
AddToMenu MyRootMenu
+ "Start LaunchTime" Module FvwmButtons -g 178x207 LaunchTime
edit: 21/05/2004 changed wording of planning section, using dia instead.

0 条评论:
发表评论
<< 主页