FVWM keybindings and titlebar buttons
To bind keys when using
x11-wm/fvwm2, you should use something like this:
Code:
#Keyname Context Modifiers Function
Mouse 2 I N Destroy
In this example middle mouse icon click will kill iconified application.
To create some titlebar buttons, add something similar to your
~/.fvwm/config file:
Code:
# Titlebar buttons click actions
AddToFunc CloseButton
+ C Close
AddToFunc IconifyButton
+ C Iconify
AddToFunc MaximizeButton
+ C Maximize
#Keyname Context Modifiers Function
Mouse 1 1 A CloseButton
Mouse 1 3 A IconifyButton
Mouse 1 5 A MaximizeButton
With this you'll get 3 left titlebar buttons. Of course, it is possible to use just "
Mouse 1 1 A Close", without creating any functions, but with these functions, titlebar buttons will be clicked only if you won't move mouse while clicking it, this prevents accidental clicking.
To customize titlebar buttons, for example, to add some png images, use something like this:
Code:
# Titlebar buttons pixmaps
ButtonStyle All ActiveUp Pixmap button.png -- Flat
ButtonStyle All Inactive Pixmap button-unfocused.png -- Flat
# Close button pressed
ButtonStyle 1 ActiveDown Pixmap button-close-pressed.png -- Flat
# Iconify button pressed
ButtonStyle 3 ActiveDown Pixmap button-iconify-pressed.png -- Flat
# Maxmimize button pressed
ButtonStyle 5 ActiveDown Pixmap button-maximize-pressed.png -- Flat
You should add
ImagePath $[FVWM_USERDIR]/dir to your
config file, then add *.png or *.xpm (or *.svg, if FVWM built with svg support) images to
~/.fvwm/dir.
Here is another example
Code:
#Keyname Context Modifiers Function
Key Q A 4 ThisWindow Close
Super+Q will close current window.
First column should be key name, like "Mouse 1" or, for example, "Key F12", to find out key name, use
x11/xev.
Second column called "Context", context means where this keybinding should be active, for example, in menu (M), on root window (R) (to use bindings with your file manager desktop, "D" should be used), in window (W), window border (S), window corner (F), while using titlebar (1357 - left buttons, 2468 - right buttons, T - titlebar in general), in icon (I), to make keybinding work everywhere, use "A".
Code:
__________________________________________________________________________________
| |
| ________ |
| F ___________________S___________________ F | ______ | |
| R |13579____T__________________T_____02468| | | |
| | | | M | |
| | | | | |
| | W W | | | |
| | | | M | |
| | | | | |
| S| |S |________| |
| R | | |
| | | |
| | W W | |
| | | R |
| |_______________________________________| |
| F S F |
| _____ _____ |
| | | | | |
| R R R | I | | I | |
| |_____| |_____| |
|__________________________________________________________________________________|
Third column is "Modifiers", this means what modifier should be used with a key, like control (C), alt (M), super (4), shift (S). To make all modifiers work with a key, use "A", if you don't want to use any modifiers at all, use "N".
Fourth column is "Function", desired function should be added here, like "Maximize", "Iconify" or some your custom function.
So adding keyboard shortcuts and titlebar buttons in FVWM is pretty simple
FVWM focus policy
By default FVWM has pretty unpredictable focus policy, when you close or iconify any window, focus will be randomly switched to icon or to another window, which may be even overlapped by another one… To make focus work as in modern WM-s (when you close/minimize current window, focus will be switched to previous non overlapped window, that was in focus before). First, disable regular FVWM focus switching, add this to your
~/.fvwm/config:
Then add
TransferFocus function:
Code:
# Send focus
AddToFunc TransferFocus
+ I Prev (CurrentDesk, AcceptsFocus, !Iconic, !Overlapped) Focus
+ I TestRc (!Match) All Reverse UseStack (CurrentDesk, AcceptsFocus, !Iconic) Focus
And add this new function to
FvwmEvent module settings (it is possible to add actions to some events with this module):
Code:
# Switch focus when switch desk or iconify/close window
*FirstEvent: iconify TransferFocus
*FirstEvent: destroy_window TransferFocus
*FirstEvent: new_desk 'All Reverse UseStack (CurrentDesk, AcceptsFocus, !Iconic) Focus'
Also FvwmEvent module should be added to FVWM startup:
Code:
AddToFunc StartFunction
+ I Module FvwmEvent FirstEvent