「FVWM」- FvwmButtons @20210123

FvwmButtons,FVWM的按钮盒子。能够在其中建立各类按钮,也能够”吞并“(Swallow)各类窗口。所谓吞并就是把某个程序窗口包含在FvwmButtons中。以下截图:算法

watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=

上面的截图中,包含了几个普通的按钮,还吞并了任务栏窗口shell

模块语法格式

Module FvwmButtons [-g geometry] [-transient | -transientpanel] [name [configfile]]less

模块描述

FvwmButtons只能由fvwm产生,命令行调用FvwmButtons模块是无效的。ide

FvwmButtons模块提供了一个按钮窗口,这个窗口能够包含不少的按钮,位于X的根窗口上的。用户能够随时按下按钮,并由窗口管理器触发用户指定的命令调用。FvwmButtons仅在使用fvwm做为窗口管理器时才有效。oop

buttonbox能够是任何配置和形状,并能够用单色或彩色图标来表示将被调用的动做,甚至其余应用程序也能够被按钮栏“吞并”,即包含到按钮栏中。测试

在点击按钮时打开面板也是能够的。有关详细信息,请参阅建立面板(CREATING PANELS)部分。字体

选项

-g
该选项指定主窗口的几何形状。命令行选项优先于配置文件中的其余几何设置。flex

-transient
告诉FvwmButtons在遇到子面板已关闭、收到第一个键或按钮按下、从新生成的状况下,关闭本身,但为了打开子面板而按下的不算。 这对于想要选择单个按钮并自动关闭的子面板特别有用。它能够用来建立二维图形菜单。因为-transient是一个选项,不是一个配置命令,你可使用相同的配置暂时和非暂时的按钮栏。动画

-transientpanel
与-transient选项大体相同,但不是关闭整个按钮栏,而是隐藏窗口。若是按钮栏做为另外一个按钮栏的子面板启动,这很是有用,由于它避免了在选择某些按钮时它必须从新启动。ui

调用(INVOCATION)

FvwmButton必须由fvwm产生,在命令行直接运行是无效的。能够经过在配置文件中使用'Module FvwmButtons OptionalName'来调用FvwmButtons。若是FvwmButtons在fvwm的初始化过程当中产生,这应该放在StartFunction中。 也能够绑定到一个菜单或鼠标按钮或手势来自动。

当使用OptionalName参数调用时,OptionalName用于查找配置命令。例如:

 

AddToFunc StartFunction Module FvwmButtons MyButtonBox

 

FvwmButtons将只使用以“*MyButtonBox”开头的行,而不是默认的“*FvwmButtons”。

配置文件中的配置选项

FvwmButtons支持的命令能够分为三类:

 

(1)用于控制FvwmButtons样式、大小、字体的命令;
(2)用于控制FvwmButtons中按钮外观的命令;
(3)用于在FvwmButtons中定义按钮以及这些按钮行为的命令;

 

下面将围绕这三类命令进行介绍。

控制FvwmButtons的选项

这些选项用于控制FvwmButtons的总体样式及行为:

*FvwmButtons: BoxSize algorithm

此选项指定FvwmButtons如何使用Rows和Columns选项(请参见下文)。它能够是dump、fixed、smart。

若是使用了fixed,而且Rows和Columns都已指定,而且非零,则FvwmButtons使用的是指定的Rows和Columns。若是该框过小以致于没法容纳全部按钮,则该模块将启动失败。

若是使用了smart,FvwmButtons将会放大框,以使全部的按钮能够适应。列的数量会增长到至少最宽按钮的宽度,并添加新的行直到能够放置全部的按钮。为了最好的容错建议使用smart选项。

选项dumb既不fixed也不smart,它是默认的。

*FvwmButtons: Rows rows

指定按钮的行数。默认为2行。

*FvwmButtons: Columns columns

指定要建立的按钮的列数。
若是未指定,则列数设置为请求的按钮数量除以行数。
若是同时指定了行和列,但按钮的数量多于行和列所容许的数量,则除非BoxSize选项fixed(即产生错误),不然将忽略columns值。

*FvwmButtons: Geometry geometry

指定FvwmButtons窗口的位置和大小。geometry值的格式是一个标准的X11中使用的格式。

*FvwmButtons: Colorset colorset

告诉模块使用colorset做为窗口的背景色。有关colorset的详细信息,请参阅FvwmTheme手册页。

*FvwmButtons: File filename

指定在文件filename中找到此按钮的配置。文件名能够是完整的路径名,或者假定是在fvwm的启动目录中。
配置文件的格式与fvwm的配置文件相同,但每一行读起来都像前缀“*FvwmButtons”同样。
注释以“#”开头;使用“\”延续当前行到下一行。

*FvwmButtons: Pixmap pixmapfile

指定要使用的背景像素图。若是想使用透明背景,则指定none。

控制按钮的选项

这些选项用于控制FvwmButtons中的按钮的公共行为和样式:

*FvwmButtons: Back color

指定按钮的背景色。浮雕和阴的影颜色是从背景色中计算的。

*FvwmButtons: ActiveColorset colorset

当鼠标悬停在按钮上方时,指示模块使用colorset做为按钮的背景色和背景图,或者做为标题颜色。

*FvwmButtons: PressColorset colorset

在按下模块的按钮时,指示模块使用colorset做为按钮的背景色和背景图,或者做为标题颜色。

*FvwmButtons: Font font

指定用于按钮的字体,或者为None。

*FvwmButtons: Fore color

指定用于按钮文本和单色图标的颜色。

*FvwmButtons: Frame width

指定每一个按钮周围的浮雕的宽度。若是这是一个负数,浮雕向内显示,使按钮看起来下沉。在激活时,按钮会抬起。

*FvwmButtons: ButtonGeometry geometry

此选项与“Geometry”选项相似,只不过尺寸是单个按钮的大小。整个FvwmButtons窗口的大小是经过将按钮尺寸乘行数和列数来计算的。

*FvwmButtons: Padding width height

此选项指定默认水平填充为width像素、垂直填充为heigh像素。除非使用了这个选项,不然根本不填充的窗口和容器除外,按钮的浮雕和按钮的其内容之间的空间一般是2像素、上下4px。

如何定义一个按钮?

下面的这条命令:

 

* FvwmButtons: (options) [title icon command]

 

用于向FvwmButtons中添加按钮,并控制按钮的内容、行为、样式等等。

[title icon command]
其中的[title icon command]字段是为了与之前版本的FvwmButtons兼容,不推荐使用:

 

  • title与选项Title name相似,若是标题字段是“-”,则不显示标题。
  • icon与Icon filename选项相似,若是icon字段是“-”,则不显示图标。
  • command与Action command选项相似,或者替代Swallow “hangon”命令。

 

鉴于此,配置文件中有关FvwmButtons的配置的格式一般为:*FvwmButtons: (options)。所以,如下介绍的选项主要针对options字段。

注意,包裹options的括号是必须的。若是有多个options,它们之间使用逗号或空格分隔。

<geometry>

指定FvwmButtons窗口或容器中按钮的大小和位置。<geometry>格式与X11中的geometry相同(<width>x<height>[+|-]<x>[+|-]<y>)。按钮的宽度为<width>乘以普通按钮的宽度、按钮的高度为<height>乘以普通按钮的高度用于指定宽高。若是给出了x和y的值,若是x(y)为正值,按钮从容器的左边(顶部)开始放置,若是x(y)是负值的,按钮从容器的右边(底部)开始放置。带有位置参数(x和y)的按钮会被放置在没有位置参数的按钮以前。若是两个或多个按钮被强制重叠,FvwmButtons将退出并显示错误消息。

Action [(options)] command

用于指定在按下Enter或Mouse时,要执行的fvwm命令command。若是command包含逗号或右括号,则须要进行引用。

Action的当前options是:Mouse n。该动做仅对鼠标按钮n执行。除了通常操做以外,还能够为每一个鼠标按钮定义一个动做。

在command部分,可使用一些预约义的变量:$left、$right、$top、$bottom,这些变量会被所按下的按钮的左、右、上、下的坐标替代。$-left、$-right、$-top、$-bottom一样会被替换,但坐标是从屏幕底部或者右边缘计算出来的(对于距右边屏幕边界5个像素的按钮, $-right将是5)。 $width和$height被按钮的宽度或高度替换。变量$fg和$bg被用Back或Fore选项设置的前景色或背景色替换(见下文)。全部这些都是无视引用字符的。字符串'$$'表示'$'。看下面的示例:

 

* FvwmButtons: (Title xload, Action (Mouse 1) `Exec exec xload -fg $fg -bg $bg -geometry -3000-3000`)

 

注意:对于2.5.0以前的fvwm版本,没法将action分配给吞并应用程序窗口的按钮(请参阅Swallow选项),只有当按钮周围的边框被点击时,这些操做才起做用。如今能够这样作了,但为了恢复旧的行为,能够在按钮上使用ActionIgnoresClientWindow:

 

* FvwmButtons: (Action beep, ActionIgnoresClientWindow, Swallow xeyes "Exec exec xeyes")

 

在这个例子中,只有当你点击按钮的边框或者Xeyes窗口的透明部分,而不是在Xeyes窗口自己时,才会执行该动做。

ActionIgnoresClientWindow

参见Action命令中的说明。

ActionOnPress

除了Popup动做以外,一般操做在按钮释放时执行。这个选项改变了这个行为,这个动做在按钮按下时执行。
例如,使用Menu或SendToModule生成弹出窗口时,是很好的。或者当Frame为0时使用,不然按钮看起来没有响应。

Back color

指定绘制此框的要使用的背景色。该值用于计算浮雕颜色及阴影颜色。

Center

按钮的内容在按钮上居中显示。这是默认的,但能够经过Left或Right改变。

Top

按钮的内容垂直方向上显示在按钮的顶部。默认是垂直居中。

Colorset colorset

给定用于容器、一个吞并的应用程序、一个简单的按钮的颜色。要将其应用于按钮或容器,只需将该选项与按钮或容器说明放在一行中便可。单个按钮及带颜色容器的绘制背景须要与X Server进行大量的通讯。因此若是你不知足几十个带有色彩背景的按钮的绘制速度,就不要在这里使用colorset。将colortset设置为被吞并应用程序的背景色则没有此限制,但这彻底取决于吞并的应用程序。它能够按照你的意愿工做,可是因为它涉及到其余应用程序的窗口,因此不能保证任何东西。我已经测试了三个应用程序:xosview能够很好地处理色彩背景;xload只能用于VGradient或纯色背景,而模拟xclock会在其处理后留下背景色。

若是吞并的窗口是fvwm模块(请参阅Swallow的(No)FvwmModule选项),则colorset不会应用于吞并的模块,应该在模块配置中使用colorset。若是吞并模块具备透明色背景,则经过吞服模块的背景的透明度显示FvwmButtons背景(而不是按钮色彩集)。有关colorset的详细信息,请参阅FvwmTheme模块的手册页。

ActiveColorset colorset

当鼠标悬停在按钮上方时,使用colorset做为按钮的背景色或背景图像及标题颜色。

PressColorset colorset

当按下按钮时,使用colorset做为按钮的背景色或背景图像及标题颜色。

Container [(options)]

指定此按钮将包含一个微型的按钮框,至关于吞并另外一个FvwmButtons模块。options与单个按钮的options相同,可是Container中的options会影响包含的全部按钮。可用的options有Back、Font、Fore、Frame、Padding。 Title和Swallow选项的Flags能够设置Title(flags)和Swallow(flags)。还应该指定“Columns width”或“Rows height”,或默认“Columns 2”。有关示例,请参阅Sample configuration部分。

Container按钮自己(与内容分离)能够采用Frame和Padding等格式选项,因此能够在Container上绑定命令,这表示你能够在Container周围加一个敏感区,用做执行Action,好比:

 

* FvwmButtons: (2x2, Frame 5, Padding 2 2, Action Beep, Container(Frame 1))

 

一般你会但愿至少给容器的大小设置<width>x<height>。

End

表示Container结束,后续的按钮定义再也不放入Container中,而放入容器的父级中。该选项应该单独给出:

 

* FvwmButtons: (End)

 

Font fontname

按钮文本使用的字体。

Fore color

设置标题和单色图标的前景色。

Frame width

按钮的浮雕的宽度,单位:px。若是宽度是负数,浮雕是向内凹陷的。激活时,按钮会抬起来。

Left

按钮的内容与左侧对齐。默认是将内容置于按钮上。

NoSize

此选项指定在进行按钮大小的初始计算时不会考虑此按钮。有用的奇怪的按钮,只是几个像素太大,保持在一行,所以炸毁你的整个buttonbox。 “NoSize”至关于“Size 0 0”。

Padding width height

    除了吞并的窗户和容器以外,按钮的浮雕与其内容之间的自由空间量一般是2像素,上下4像素,默认状况下根本不填充。此选项将水平填充设置为宽度,将垂直填充设置为高度。

Icon filename

要在按钮上显示的图标的图像文件名。FvwmButtons搜索fvwm中ImagePath配置项指定的路径来查找图标文件。

ActiveIcon filename

图像文件的名称。当鼠标悬停在按钮上方时按钮上显示的图标。若是没有指定ActiveIcon,将显示由Icon指定的图像(若是有的话)。

PressIcon filename

图像文件的名称。在按钮按下时按钮上显示的图标。若是没有指定PressIcon,将显示由Icon指定的图像(若是有的话)。

Id id

id用来标识这个按钮。id的第一个字符应该是字母。另见“DYNAMICAL ACTIONS”部分。

Left

按钮的内容左对其。默认是居中的。

NoSize

此选项指定在进行按钮大小的初始计算时不会考虑此按钮。对奇怪的按钮因为,只是几个像素太大,没法保持在一行,所以弄乱整个buttonbox。“NoSize”至关于“Size 0 0”。

Padding width height

除了吞并的窗户和容器以外,按钮的浮雕与其内容之间的空间,一般是2px,上下4px,默认状况下根本不填充。此选项将水平填充设置为width,将垂直填充设置为height。

Right

该按钮的内容与右侧对齐。默认居中。

Size width height

指定按钮内容的宽高,单位像素,而忽略FvwmButton从图标和标题计算的大小。若是没有指定此选项,只有吞咽窗口的按钮栏不会变得很大,由于FvwmButtons不考虑吞咽按钮的大小。请注意,这个选项能够保证最小的空间;其余按钮可能须要buttonbox使用更大的尺寸。

Swallow [(flags)] hangon command

窗口吞并。遍历全部窗口,当遇到第一个窗口的Name、Class、Resource之一与hangon匹配时,FvwmButtons会捕获该窗口,并将该窗口显示在FvwmButtons中。

下面是一个使用Swallow的例子:

 

* FvwmButtons: (Swallow XClock 'Exec xclock -geometry -3000-3000 &')

 

如上示例,遍历全部窗口,在遇到Name、Class、Resource之一为“XClock”的的第一个窗口时,将该窗口显示FvwmButtons中。若是找不到匹配的窗口,则执行后面的“Exec”命令来建立一个。xclock命令的参数“-geometry -3000-3000”使窗口在被FvwmButtons吞并以前显示在屏幕以外,不然的话你会看到一个窗口闪过。

hangon:用于匹配窗口的Name、Class、Resource,当它们之一与hangon匹配时,将FvwmButtons会捕获该窗口,并将窗口吞入到该按钮中。hangon能够包含通配符星号('*'),用于匹配任何子字符串。
command:若是找不到与hangon匹配的窗口时,则执行command命令来建立一个。注意,Exec命令所建立的窗口的Name、Class、Resource之一也必须与hangon匹配。与上面Action选项中描述的同样,Swallow也会替换command中的$fg和$bg变量。可是注意,若是使用UseOld和NoClose选项时,在FvwmButtons从新启动时,被吞并的应用程序是不会从新启动的。在这种状况下,若是更改了command,重启FvwmButtons时,应用是不会发生变化的。
flags:用于控制Swallow的行为。

也能够被吞并FVWM模块。以下示例:

 

* FvwmButtons: (Swallow "FvwmPager" "FvwmPager 0 0")

 

可用的flags以下:

 

NoClose / Close - 当FvwmButtons彻底退出(好比,重启)时,此按钮中被吞并的程序是否被”吐出来“或者关闭。默认值是“Close”。“NoClose”能够与“UseOld”组合时,会使被吞并的窗口在FVWM从新启动的状况下依旧存在。

 

 

NoHints / Hints - 是否忽略该按钮中被吞并程序的提示。这有助于窗口调整其自身大小,以适应按钮。默认值是“Hints”。

 

 

NoKill / Kill - 指定吞并的程序是经过被杀死来关闭,仍是经过发送消息来关闭。在结束不接受窗口管理器协议的程序时很是有用。默认值是“NoKill”。若是指定了“NoClose”,则”Kill“不起做用。

 

 

NoRespawn / Respawn / SwallowNew - 若是被吞并的程序死了,是否要从新启动。默认值是”NoRespawn“。若是指定了“Respawn”,则使用原始命令从新启动程序。当心使用这个选项,程序可能有本身退出的合理理由。若是给出了“SwallowNew”,则程序不会从新生成,可是若是出现具备 hangon名称的新窗口,则会被当即吞并。

 

 

NoOld / UseOld - 指定在使用command产生一个新窗口以前,按钮是否会尝试吞并一个与hangon匹配的、已经存在的窗口。缺省值是“NoOld”。“UseOld”与“NoKill”组合,使窗口能够在窗口管理器的从新启动中存活下来。若是你想让FvwmButtons吞并一个旧窗口,但失败时又不会本身产生一个,可指定command为“Nop”,以下示例:

 

 

* FvwmButtons: (Swallow (UseOld) "Console" Nop)

 

 

若是你想经过本身点击当前按钮来启动它,将它与一个Action结合起来:

 

 

* FvwmButtons: (Swallow (UseOld) "Console" Nop, Action `Exec "Console" console &`)

 

 

NoTitle / UseTitle - 指定是否从被吞并的窗口标题中获取按钮的标题。若是给出“UseTitle”,则按钮上的标题会动态变化,以反映窗口名称。默认是“NoTitle”。

 

 

NoFvwmModule / FvwmModule - 默认状况下,若是command的前4个字母是“Fvwm”,或者命令的前6个字母是“Module”,则FvwmButtons将吞并的窗口视为FVWM模块窗口。使用NoFvwmModule和FvwmModule来覆盖这个逻辑。

 

Panel [ (options) ] hangon command

命令Panel与Swallow命令很是类似,均可以吞并窗口,可是Panel命令不会将吞并的窗口显示出来,直到用户按下Panel按钮时,Panel才以滑动动画打开被吞并的窗口。

参数(options)能够是:

 

  • 用于Swallow命令中描述的任何flags参数。
  • 除此以外,还包含了“left”、“right”、“up”、“down”选项来指定滑动方向。
  • 选项steps animation-steps定义了动画步骤的数量。
  • 选项delay ms设置动画步之间的延迟,以毫秒为单位。值ms为”0“表示不延迟。最大延迟时间是10秒(10000)。不使用smooth选项时使用delay选项没有任何意义。
  • 选项smooth会使Panel在动画的各个步之间重绘。这样滑动动画可能会更平滑,这取决于应用程序、显示速度。应用程序可能会增加,而不是滑出。动画可能会变慢。
  • 选项Hints会致使FvwmButtons使用应用程序大小提示来计算动画步骤的大小。Hints是默认的。若是步数不是您想要的,请尝试使用NoHints
  • 选项noborder告诉FvwmButtons在计算动画的位置(至关于在position选项中设置noplr和noptb)时,忽略窗口的边界。
  • 选项indicator若是设置了,FvwmButtons将在按钮中绘制一个小三角形,用于打开一个面板。三角形指向面板将弹出的方向。关键字indicator后可跟一个正整数,指定indicator的最大宽度和高度,若是没有这个大小FvwmButtons将使indicator适合按钮。您可能会想要使用“Padding”选项在indicator和按钮的边框之间留下几个像素。
  • 选项position容许放置面板。语法是position [context-window] [pos] [x y] [border-opts]。参数context-window指的是用于从中计算Panel百分比偏移量的窗口。能够是Button、Module、Root之一:Button指定面板的按钮;Module指定FvwmButtons自己;Root指定一个虚拟屏幕。context-window与滑动方向一块儿定义一个线段,该线段是context-window的边界之一:用于上/下/左/右滑动的上/下/左/右边界。参数pos能够是:center、left/right (用于上下滑动)、top/bottom (用于左右滑动)中的一个。它定义线段上的面板的垂直(向上和向下滑动)或水平(向左和向右滑动)位置。例如,若是pos使用left,则向上滑动,则面板的左侧边界和context-window的左侧边界将对齐。偏移值xy指定面板从默认位置移动多远。默认状况下,给定的数值被解释为context-window的宽度(高度)的百分比。以“p”结尾将数值解释为“像素”。即便使用Root为上下文,全部偏移量的计算都是相对于按钮位置的。border-opts可用的值为:mlr、mtb、noplr、noptb。用于定义包含哪些边界的宽度。默认状况下,不考虑FvwmButtons的边界。mlr改变左侧和右侧边界的默认值,mtb改变顶部和底部边界的默认值。相反,默认状况下,Panel的边界被考虑在内。noplr改变默认的左边界和右边界,noptb改变顶部和底部边界的默认值。

 

默认向上滑动5毫秒,动画共12步骤。要在没有任何动画的状况下显示面板,请将step设置为零。默认位置是“Button center”。

有关面板的更多信息,请参阅“CREATING PANELS”部分。

示例以下:

 

# To include the panel in a button
* FvwmButtons: (Panel(down, delay 0, steps 16) SubPanel "Module FvwmButtons SubPanel")
# To define the panel as an instance of
# FvwmButtons with a different name:
* SubPanel: (Icon my_lock.xpm, Action Exec xlock)
* SubPanel: (Icon my_move.xpm, Action Move)
...

 

Title [(options)] name

指定按钮上的标题。空格能够经过引用来包含在标题中。若是一个标题在任什么时候候对于按钮来讲都太长,超出的字符会被截断。 若是justify是“Right”,头部被移除,不然尾部被移除。options取值以下:

 

Center - 标题水平居中。 这是默认的。
Left - 标题在左侧是合理的。
Right - 居右。
Side - 使标题出如今任何图标或吞咽窗口的右侧,而不是默认的下面。若是使用小图标,并将其与“Left”或“Right”选项相结合,可使其看起来相似于fvwm的菜单。

 

ActiveTitle name

鼠标悬停在按钮上方时,显示的标题。若是没有指定ActiveTitle,则显示由Title指定的文本(若是有的话)。

PressTitle name

按下按钮时,显示的标题。若是没有指定PressTitle,则显示由Title指定的文本(若是有的话)。

关于command的内容
任何fvwm命令都被FvwmButtons识别。有关更多信息,请参见fvwm(1)。
Exec命令用在Actions中时有一个小扩展,其语法是:

 

Exec ["hangon"] command

 

好比:

 

* FvwmButtons: (Action Exec "xload" xload)

 

hangon字符串必须用双引号括起来。当FvwmButtons找到这样一个Exec命令时,该按钮保持推入状态,直到遇到Name、Class、Resource与命令引用部分相匹配的窗口。这是为了向用户反馈当前操做正在执行而给出的视觉反馈。hangon字符串可能包含匹配任何子字符串的通配符('*')。 若是引用的部分不包含字符(""),则该按钮将当即弹出。请注意,即便按钮看起来被按下了,但用户能够继续按下按钮,并从新执行该命令。

Quoting
任何包含空格的字符串都必须加引号。与早期版本相反的是命令再也不须要引用。在这种状况下,任何引用字符都将被传递给应用程序。 只有逗号','和右括号')'必须在命令中进行引用。引用能够用三个引号字符中的任何一个来完成:

 

  • 单引号:'Thisisa“引号”'
  • 双引号:"It'sanother`quote'"
  • 反引号:`Thisisastrangequote`

 

反引号使用并不常见,但会有目的地使用,若是你使用像FvwmCpp这样的预处理器,并但愿它进入你的命令,像这样:

 

#define BG gray60
* FvwmButtons:(Swallow "xload" `Exec xload -bg BG&`)

 

任何单个字符均可以用前面的反斜杠“\”来引用。

建立面板(CREATING PANELS)

前版本的FvwmButtons(fvwm 2.0.46到2.3.6)有不一样的处理面板的方法。新面板功能中不能使用旧面板配置。阅读“CONVERTING OLD PANEL CONFIGURATIONS”以获取更多信息。

如何建立一个新的面板(HOW TO CREATE NEW PANELS)

这里侧重讲解Panel的使用。

任何能够在fvwm中启动的有窗口的程序均可以用做面板。一个终端窗口多是你的面板,或者一些应用程序(如xload、xosview),另外一个fvwm模块,包括FvwmButtons自己。全部你须要知道的是如何从fvwm中启动你的应用程序。

调用面板的按钮与其余按钮同样易于配置。本质上你只须要Panel选项:

 

* FvwmButtons: (Panel my_first_panel "Module FvwmButtons -g -30000-30000 my_first_panel")
* FvwmButtons: (Panel my_second_panel "Exec exec xterm -g -30000-30000 -n my_second_panel")

 

这与Swallow选项相似。不一样之处在于应用程序在启动时没有放入按钮,而是隐藏起来。当您按下面板按钮时,窗口会滑入视图中。 '-g -30000-30000'选项告诉应用程序应该在可见屏幕的顶部和左边很远的地方建立它。不然,当FvwmButtons启动时,您会看到它闪烁一下子。有些应用程序不适合这种语法,因此你可能不得不忍受短暂的窗口闪烁。若是你想从另一个FvwmButton实例中建立一个面板,你能够这样作,可是你必须给它一个不一样的名字(上面例子中的'my_first_panel')。若是在相同名称下运行FvwmButtons,则会递归地建立新面板,直到系统资源耗尽而且FvwmButtons崩溃!要使用不一样的名称配置第二个按钮栏,只需在配置文件中将“*new_name”替换为“*FvwmButtons”。若是您不熟悉Swallow选项,或者想要了解更多关于吞咽面板的工做原理,请参阅Swallow选项的说明。

如今,面板基本上能够工做,你须要将须要调整一下。若是不须要面板上的窗口标题,使用fvwm的Style命令。若是按钮栏是“粘”住的,你可能还想使面板也粘住。可能面板窗口不该该由图标,以防止其图标化。Style的配置以下:

 

Style <name_of_panel_window> NoTitle, Sitcky, NoIcon

 

你可能但愿你的面板保持打开状态,直到你选择了一些东西,能够在命令中的-g选项以后为FvwmButtons提供-transientpanel选项。FvwmPager有一个相似的选项“-transient”。

最后但并不是最不重要的是,如今能够在按钮中放置一个图标、一个标题、一个小箭头,以即可以看到它的做用。标题或图标能够照常指定。 要激活箭头,只需在上面的示例中的“Panel”关键字后面添加“(indicator)”,并使用“Padding”选项在箭头和按钮边框之间留下几个像素。面板打开时的可选方向也能够一并给出:

 

* FvwmButtons: (Padding 2, Panel(down, indicator) my_first_panel \
"Module FvwmButtons -g -30000-30000 -transientpanel my_first_panel")

 

还有几个选项能够用于配置面板如何工做,例如滑动动画的速度和平滑度。有关更多详细信息,请参阅Panel选项的说明。

旧配置文件的转换(CONVERTING OLD PANEL CONFIGURATIONS)

This section describes how to convert a pretty old syntax used in 2.2.x
versions. You may skip it if your syntax is more recent.
With the old panel feature you first had one or more lines defining panels in
your main FvwmButtons configuration:

...
*FvwmButtons(Title WinOps,Panel WinOps)
*FvwmButtons(Title Tools ,Panel Tools)
...
After the last configuration line for the main panel the configuration of the
first panel followed, introduced with a line beginning with *FvwmButtonsPanel:

*FvwmButtonsPanel WinOps
*FvwmButtonsBack bisque2
...

*FvwmButtonsPanel Tools
*FvwmButtonsBack bisque2
...
And perhaps you had style commands for you panels:

Style FvwmButtonsPanel Title, NoHandles, BorderWidth 0
Style FvwmButtonsPanel NoButton 2, NoButton 4, Sticky
The new configuration looks much the same, but now the configuration of the
main panel is independent of the configuration of the sub panels. The lines
invoking the panels use the same syntax as the Swallow option, so you simply
add the name of the window to use as a panel and the command to execute instead
of the panel name. Note that you give the new instance of FvwmButtons a
different name.

*FvwmButtons: (Title WinOps, Panel WinOps \
"Module FvwmButtons WinOps")
*FvwmButtons: (Title Tools , Panel Tools \
"Module FvwmButtons Tools")
If you used something like 'Panel-d' you now have to use 'Panel(down)' instead.
To make the new panel vanish as soon as a button was selected start FvwmButtons
with the '-transientpanel' option:

*FvwmButtons: (Title Tools , Panel(down) Tools \
"Module FvwmButtons -transientpanel Tools")
The rest of the configuration is very easy to change. Delete the lines
'*FvwmButtonsPanel <name>' and add <name> to all of the following configuration
lines for the panel instead. Use the same name in your Style commands:

*WinOps: Back bisque2
...
*Tools: Back bisque2
...
Style "WinOps" Title, NoHandles, BorderWidth 0
Style "WinOps" NoButton 2, NoButton 4, Sticky
Style "Tools" Title, NoHandles, BorderWidth 0
Style "Tools" NoButton 2, NoButton 4, Sticky
That's it. The new panels are much more flexible. Please refer to other parts
of this documentation for details.

WHY WAS THE PANEL FEATURE REWRITTEN?

有几个缘由。 其中最重要的一点是执行面板的程序代码很是具备破坏性,形成了不少问题。 同时它也使得FvwmButtons的编写新功能变得困难。 第二个缘由是大多数用户根本没法使其工做 - 这太复杂了。 即便我(新代码的做者)在第一次工做以前也要花费几个小时的时间。 第三个缘由是新面板更通用。 任何应用程序均可以是FvwmButtons中的一个面板,而不只仅是FvwmButtons自己的其余实例。 因此我衷心但愿没有人为这个变化而生气。 是的 - 你必须改变你的配置,但新功能配置起来要容易得多,特别是若是你已经知道Swallow选项的工做方式。

排列算法(ARRANGEMENT ALGORITHM)

FvwmButtons试图经过递归地在包括buttonbox自己的每一个容器上使用如下的算法来尽量地安排它的按钮:

Getting the size right
首先,经过将每一个按钮的width*height相加来得到须要的按钮单元区域。容器暂时被认为是一个正常的按钮。而后它使用给定的Rows和Columns参数。若是给出的Rows,它将计算须要多少列(Columns),并使用该Columns值,除非Columns较大,在这种状况下,会在buttonbox的底部获得一些空的空间。若是给出了Columns的数量,它会计算出全部按钮须要多少行(Rows)。若是Rows和Columns都没有给出,它假定你想要Rows为2,并计算出Columns的值。若是将BoxSize选项设置为smart,则至少使用最高/最宽按钮的高度/宽度,而fixed值可防止在行和列都设置为非零时从新调整框的大小。

Shuffling buttons
如今它有一个足够大的区域放置按钮,剩下的就是把它们放在正确的位置。有两种按钮:固定按钮和浮动按钮。 经过x/y参数将固定按钮强制放到按钮框中的特定槽中。全部其余按钮被认为是浮动的。固定的按钮首先被放置。若是一个固定的按钮与另外一个按钮重叠,或者应该放在按钮窗口以外,则FvwmButtons会退出并显示一条错误消息。以后,浮动按钮被放置。 该算法试图将按钮从左到右,从上到下的风格。若是按钮位于建议的位置,则放置在该位置,不然当前插槽保持空白,而且将考虑右侧的插槽。 在按钮被放置后,下一个按钮被尝试放置在下一个槽中,依此类推,直到全部的按钮被放置。若是使用BoxSize选项smart,则在按钮底部的行下方会添加其余行,直到全部按钮都被放置为止。

Containers
Containers按照相同的算法进行排列,实际上它们是在算法找到它们时递归地进行混洗的。

Clarifying example
一个例子:假设你有6个按钮,全部的大小都为单位大小,除了第二个是2×2,即5*1+1*4=9,9个单位按钮面积。假设已经要求Columns为3。摆放次序以下:

 1) +---+---+---+   2) +---+---+---+   3) +---+---+---+
	| 1 |       |      | 1 |       |      | 1 |       |
	+---+       +      +---+   2   +      +---+   2   +
	|           |      |   |       |      | 3 |       |
	+           +      +   +---+---+      +---+---+---+
	|           |      |           |      |   |   |   |
	+-----------+      +---+-------+      +---+---+---+

 4) +---+---+---+   5) +---+-------+   6) +---+-------+
	| 1 |       |      | 1 |       |      | 1 |       |
	+---+   2   +      +---+   2   |      +---+   2   |
	| 3 |       |      | 3 |       |      | 3 |       |
	+---+---+---+      +---+---+---+      +---+-------+
	| 4 |       |      | 4 | 5 |   |      | 4 | 5 | 6 |
	+---+---+---+      +---+---+---+      +---+---+---+

What size will the buttons be?
当FvwmButtons读取其配置所需的图标和字体时,能够找出每一个非吞咽按钮所需的大小。容器的单位按钮的尺寸被设置为足够大以容纳最大的按钮而不挤压它。简单地说,吞并的窗户对于从这个方案中获得的按钮大小来讲是温馨的。 若是一个特定的配置须要更多的空间来放置一个被吞并的窗口,可使用选项“Size width height”来设置该按钮。这将告诉FvwmButtons给这个按钮在浮雕和填充中至少宽度、高度的像素。

DYNAMICAL ACTIONS

A running FvwmButtons instance may receive some commands at run time. This is
achieved using the fvwm command

SendToModule FvwmButtons-Alias <action> <params>
Supported actions:
ChangeButton button_id options

can be used to change the title or icon of a button at run time.
button_id is the id of the button to change as specified using the Id
button option. It may also be a number, in this case the button with the
given number is assumed. And finally, button_id may be in the form +x+y,
where x and y are a column number and a row number of the button to be
changed. It is possible to specify multiple option pairs (name with
value) by delimiting them using comma. Currently options include Title,
ActiveTitle, PressTitle, Colorset, Icon, ActiveIcon and PressIcon. These
options work like the configuration options of the same name.
ExpandButtonVars button_id command
replaces variables present in the command exactly like in the Action
button option and then sends the command back to fvwm. button_id has the
same syntax as described in ChangeButton above.
PressButton button_id [mouse_button]
simulates a mouse click on a button. button_id is the id of the button to
press as specified using the Id button option and mouse_button is the
number of mouse button used to click on the button e.g "1" for the left
mouse button etc. Quotes around the number are not necessary. If
mouse_button option is omitted, mouse button 1 is assumed. This command
behaves exactly as if the mouse button was pressed and released on the
button on in question.
Silent
This prefix may be specified before other actions. It disables all
possible error and warning messages.
Example:

 

 

*FvwmButtons: (Id note1, Title "13:30 - Dinner", Icon clock1.xpm)

 

 

SendToModule FvwmButtons Silent \
ChangeButton note1 Icon clock2.xpm, Title "18:00 - Go Home"

 

简单的配置示例(SAMPLE CONFIGURATION)

如下是描述FvwmButtons初始化命令,摘录自.fvwm2rc文件:

##########################################################
# Load any modules which should be started during fvwm
# initialization

# Make sure FvwmButtons is always there.
AddToFunc StartFunction  "I" Module FvwmButtons

# Make it titlebar-less, sticky, and give it an icon
Style "FvwmButtons"     Icon toolbox.xpm, NoTitle, Sticky

# Make the menu/panel look like CDE
Style "WinOps" Title, NoHandles, BorderWidth 0
Style "WinOps" NoButton 2, NoButton 4, Sticky
Style "Tools" Title, NoHandles, BorderWidth 0
Style "Tools" NoButton 2, NoButton 4, Sticky

##########################################################
DestroyModuleConfig FvwmButtons: *
*FvwmButtons: Fore Black
*FvwmButtons: Back rgb:90/80/90
*FvwmButtons: Geometry -135-5
*FvwmButtons: Rows 1
*FvwmButtons: BoxSize smart
*FvwmButtons: Font -*-helvetica-medium-r-*-*-12-*
*FvwmButtons: Padding 2 2

*FvwmButtons: (Title WinOps, Panel WinOps "Module FvwmButtons -transientpanel WinOps")
*FvwmButtons: (Title Tools, Panel Tools "Module FvwmButtons -transientpanel Tools")

*FvwmButtons: (Title Resize, Icon resize.xpm,  Action Resize)
*FvwmButtons: (Title Move,   Icon arrows2.xpm, Action Move  )
*FvwmButtons: (Title Lower,  Icon Down,        Action Lower )
*FvwmButtons: (Title Raise,  Icon Up,          Action Raise )
*FvwmButtons: (Title Kill,   Icon bomb.xpm,    Action Destroy)

*FvwmButtons: (1x1,Container(Rows 3,Frame 1))
*FvwmButtons: (Title Dopey ,Action `Exec "big_win" xterm -T big_win -geometry 80x50 &`)
*FvwmButtons: (Title Snoopy, Font fixed, Action `Exec "small_win" xterm -T small_win &`)
*FvwmButtons: (Title Smokin')
*FvwmButtons: (End)

*FvwmButtons: (Title Xcalc, Icon rcalc.xpm, Action `Exec "Calculator" xcalc &`)
*FvwmButtons: (Title XMag, Icon magnifying_glass2.xpm, Action `Exec "xmag" xmag &`)
*FvwmButtons: (Title Mail, Icon mail2.xpm, Action `Exec "xmh" xmh &`)
*FvwmButtons: (4x1, Swallow "FvwmPager" `FvwmPager 0 3` Frame 3)

*FvwmButtons: (Swallow(UseOld,NoKill) "xload15" `Exec xload \
 -title xload15 -nolabel -bg rgb:90/80/90 -update 15    \
 -geometry -3000-3000 &`)

倒数第二行,做用是一个产生一个FvwmPager模块,并将它显示在一个四倍宽度的按钮中。被使用时,Pager将尽量的填满按钮。

最后一行更神奇。注意UseOld和NoKill的组合,当启动时,它会试图“吞并”名为“xload15”的现有窗口,若是失败了,则使用指定的命令启动一个名为xload15的窗口,当结束FvwmButtons时,该窗口会被“吐”出来。吞并的应用程序以“-geometry -3000-3000”启动,以便在“吞并”以前不可见。

其余面板在root面板以后指定:

########## PANEL WinOps
DestroyModuleConfig WinOps: *
*WinOps: Back bisque2
*WinOps: Geometry -3-3
*WinOps: Columns 1

*WinOps: (Title Resize, Icon resize.xpm,  Action Resize)
*WinOps: (Title Move,   Icon arrows2.xpm, Action Move  )
*WinOps: (Title Lower,  Icon Down,        Action Lower )
*WinOps: (Title Raise,  Icon Up,          Action Raise )

########## PANEL Tools
DestroyModuleConfig Tools: *
*Tools: Back bisque2
*Tools: Geometry -1-1
*Tools: Columns 1

*Tools: (Title Kill,    Icon bomb.xpm,    Action Destroy)

颜色规范中rgb:90/80/90是X中指定独立颜色的正确方法,而不该该使用旧的#908090。 若是在你的配置文件中使用了后面的规范,那么应该使用反斜线(\)对井号(#)进行转义,不然剩下部分会被解析成注释。

请注意,使用x/y几何图形规格,能够轻松地构建带间隙的按钮窗口。下面是另外一个例子。若是没有按钮的几何规格,则没法完成此操做:

##########################################################
# Another example
##########################################################

# Make it titlebar-less, sticky, and give it an icon
Style "FvwmButtons"     Icon toolbox.xpm, NoTitle, Sticky

DestroyModuleConfig FvwmButtons: *
*FvwmButtons: Font        5x7
*FvwmButtons: Back rgb:90/80/90
*FvwmButtons: Fore        black
*FvwmButtons: Frame       1
# 9x11 pixels per button, 4x4 pixels for the frame
*FvwmButtons: Geometry    580x59+0-0
*FvwmButtons: Rows        5
*FvwmButtons: Columns     64
*FvwmButtons: BoxSize     fixed
*FvwmButtons: Padding     1 1

# Pop up a module menu directly above the button.
*FvwmButtons: (9x1+3+0, Padding 0, Title "Modules",   \
  Action `Menu Modulepopup rectangle $widthx$height+$lleft+$top o+50 -100m`)

# first row of buttons from left to right:
*FvwmButtons: (3x2+0+1, Icon my_lock.xpm, Action `Exec xlock`)
*FvwmButtons: (3x2+3+1, Icon my_recapture.xpm, Action Recapture)
*FvwmButtons: (3x2+6+1, Icon my_resize.xpm, Action Resize)
*FvwmButtons: (3x2+9+1, Icon my_move.xpm, Action Move)
*FvwmButtons: (3x2+12+1, Icon my_fvwmconsole.xpm, Action 'Module FvwmConsole')

# second row of buttons from left to right:
*FvwmButtons: (3x2+0+3, Icon my_exit.xpm, Action QuitSave)
*FvwmButtons: (3x2+3+3, Icon my_restart.xpm, Action Restart)
*FvwmButtons: (3x2+6+3, Icon my_kill.xpm, Action Destroy)
*FvwmButtons: (3x2+9+3, Icon my_shell.xpm, Action 'Exec rxvt')

# big items
*FvwmButtons: (10x5, Swallow (NoKill, NoCLose) "FvwmPager" 'FvwmPager * * -geometry 40x40-1024-1024')
*FvwmButtons: (6x5, Swallow "FvwmXclock" `Exec xclock \
  -name FvwmXclock -geometry 40x40+0-3000 -padding 1  \
  -analog -chime -bg rgb:90/80/90`)
*FvwmButtons: (13x5, Swallow (NoClose) "FvwmIconMan" 'Module FvwmIconMan')
*FvwmButtons: (20x5, Padding 0, Swallow "xosview"     \
  `Exec /usr/X11R6/bin/xosview -cpu -int -page -net   \
  -geometry 100x50+0-3000 -font 5x7`)

存在的问题(BUGS)

Swallow选项的动做(action)部分若是包含了空格,则必须进行引用。

参考文献

 

  • WikiNotes/FvwmButtons
  • FVWM/FvwmButtons
相关文章
相关标签/搜索