Fluxbox Wiki
KeyModes
What are KeyModes?
KeyModes are a way to create modes or "namespaces" within the keybindings of Fluxbox. They create a context for Fluxbox's keybindings and can be used in any way you see fit to make Fluxbox behave the way you want it to. The most common use for KeyModes is window resizing and movement.
Example:
Mod4 Shift Up :ResizeVertical -2 Mod4 Shift Down :ResizeVertical +2 Mod4 Shift Left :ResizeHorizontal -2 Mod4 Shift Right :ResizeHorizontal +2 Mod1 Shift Up :ResizeVertical -10 Mod1 Shift Down :ResizeVertical +10 Mod1 Shift Left :ResizeHorizontal -10 Mod1 Shift Right :ResizeHorizontal +10
As you can see, you run out of usable hotkeys for actions like that pretty quickly. KeyModes alleviate this "namespace clutter" and provide an elegant solution for this use-case.
What do I need to use KeyModes?
KeyModes have been available since revision 4298 and/or version 1.0rc. Using any recent version of Fluxbox guarantees you can use KeyModes!
How do I use KeyModes?
You'll use the syntax below, inside ~/.fluxbox/keys
:
[KeyMode:] [mod mod] key [key key] :command command-options
If you don't define a KeyMode, the default KeyMode is used instead. To use a mapping inside a KeyMode, use the KeyMode prefix at the beginning of your definition:
:KeyMode ModeName [mod [mod mod ...] key [key key ...]]
The last mod...key
combination is used to get back into the default KeyMode. If this is not defined, the default is bound to Esc.
Examples
Here are a few examples of resizing and moving windows that someone might want to add to their keys
file.
Resizing windows, exiting with Esc
# ResizeMode Mod4 w Mod4 r :KeyMode ResizeMode ResizeMode: None Up :ResizeVertical -2 ResizeMode: None Down :ResizeVertical +2 ResizeMode: None Left :ResizeHorizontal -2 ResizeMode: None Right :ResizeHorizontal +2 ResizeMode: Shift Up :ResizeVertical -10 ResizeMode: Shift Down :ResizeVertical +10 ResizeMode: Shift Left :ResizeHorizontal -10 ResizeMode: Shift Right :ResizeHorizontal +10
Moving windows, exiting with Esc
# MoveMode Mod4 w Mod4 m :KeyMode MoveMode MoveMode: None Up :MoveUp 2 MoveMode: None Down :MoveDown 2 MoveMode: None Left :MoveLeft 2 MoveMode: None Right :MoveRight 2 MoveMode: Shift Up :MoveUp 10 MoveMode: Shift Down :MoveDown 10 MoveMode: Shift Left :MoveLeft 10 MoveMode: Shift Right :MoveRight 10
Disable all keybindings (e.g. using with Xnest)
# XnestMode
Mod1 x :KeyMode XnestMode
Mode Indicator
This is a crude example of what you could use to provide an on-screen indicator that you've changed modes:
Mod4 w Mod4 r :MacroCmd {Exec echo "Resize Mode" | osd_cat -d 1 -p bottom -A center} {KeyMode ResizeMode}
Other programs are also possible, such as inotify
or even xcowsay
! Your imagination is the limit.