本文根据我的个人理解翻译整理,原文地址: http://forums.gentoo.org/viewtopic.php?t=162177 。
感谢强悍的 taviso
利用 FwmButton 实现如下效果

主要特点:9个 button,一个 xclock
Step 1. 构思
利用 GIMP、xpaint、dia 或 xfig 等工具画出构思的草图。下图是作者利用 dia 画出的草图:

Step 2. 确定尺寸
计算需要的格子数目(以最小的行高或栏宽为一格,这个原则体现在 FvwmButton 的多个地方,需要好好把握),见下图,在纵向上来说,因为第一行行高最低,所以可以以第一行为一格,所以纵向有7格。在横向上来说就无所谓了,等宽,所以记做3格。

Step 3. 新建 Buttons
利用最简单的 FvwmButtons 配置项测试设计的尺寸是否合适。代码如下:
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)
可以看到,针对 panel 的配置每一行都以 * 号开始,紧跟着是 panel 的 alias。那些不包含 ( ) 的行是 settings,包含 ( ) 的是 button definitions。这里的 button definition 只做了7行3栏的定义。
Now lets try starting the panel, enter the following into your FvwmConsole. (注:关于 FvwmConsole 的解释见:http://www.fvwm.org/documentation/manpages/stable/FvwmConsole.php 。FvwmConsole 只能被fvwm调用(fork),不能从命令行启动。FvwmConsole 通过一个控制台终端交互式的接收用户输入的 fvwm 配置命令,并立即执行。可以利用它来测试新的配置,或者暂时地改变 fvwm 的外观。FvwmConsole 能够解析所有的xterm选项。可以在.fvwm2rc 文件的初始化函数里使用命令‘Moudle FvwmConsole’启动 FvwmConsole,也可以将这个命令与菜单操作、鼠标操作或key-stroke绑定。FvwmConsole 使用xterm作为自己的控制台。)
Module FvwmButtons -g 178x207 LaunchTime
-g 参数告诉 FvwmButton 需要多大的 panel 以及在具体在页面上的位置。(个人理解:此处是 178像素×207像素的矩形区域,后面没有添加 +0-0 之类的参数,应该是因为 FvwmButton 有个默认值。)
正常的话,应该可以看到如下的图:

Step 4. 填充 Blanks
任何应用程序窗口都可以被用作 button 放置在面板上,这在 FvwmButtons 中这个动作叫做 swallow (吞吃?^_^,还是一口吃下哦,比较可怕的!)
我们先尝试 swallow xclock 这个应用程序:
将如下关于 xclock 的代码应用到 panel 上
xclock -bg '#31658c' -fg white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y %H:%M'
即:
*LaunchTime: (3x1, Swallow "xclock" `Exec xclock -bg '#31658c' -fg white -digital -face 'Aquafont:size=11' -strftime '%a, %d %b %Y %H:%M'`)
3×1 表示横向跨3格,纵向跨1格,然后是 Swallow 这个动作,然后是执行 xclock 的配置项。
完整代码如下:
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)
在 FvwmConsole 中输入如上配置代码,启动 panel 测试是否配置正确。正常的话会得到下图所示窗口:

下面测试下一个 button,里面放置 GIMP,代码:
*LaunchTime: (1x2, Title "gimp", Icon graphics_paint_edit.png)
同时我们希望点击鼠标左键后启动 GIMP 程序,代码:
Action(Mouse 1) `Exec gimp`
同理,我们针对其他应用程序在配置文件中做同样操作,现在的整个配置文件如下:
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`)
启动 panel,应该可以看到如下所示图形:

Step 5. 优化 panel
针对 panel 做进一步优化,设置 Colorsets, Fonts, Frames, Padding 和任何其他希望的样式!整个代码如下:
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`)
在 FvwmConsole 中键入:Module FvwmButtons -g 178×207 LaunchTime ,结果如下:

进一步优化:
希望 LaunchTime 总是可见,不被其他窗体覆盖:
Style LaunchTime StaysOnTop
每次在 Fvwm 启动的时候自动启动:
AddToFunc StartFunction + I Module FvwmButtons -g 178x207 LaunchTime
添加到 menu 菜单中:
AddToMenu MyRootMenu + "Start LaunchTime" Module FvwmButtons -g 178x207 LaunchTime
Possibly Related Posts: (Automatically Generated)
Tags: config, configuration, FVWM, panel, taviso
真谢谢你这里还有图片, 我先找到的原版的, 但图片链接都已经失效了.
谢谢!!!!
[Reply]