Keyboard shortcuts
From Fluxbox-wiki
Contents |
How to use the keys file
The keys file is usually ~/.fluxbox/keys. It can be edited with an editor of your choice. When you're done editing, select "Reload config" from the menu for your changes to take effect. As an alternative, you can bind a key to Reconfigure as described below. The following is basically stolen from akira's keyfile. Take a look at it since it's the most complete one.
The syntax for a keybinding is quite easy:
<mod> [<mod> <mod>] key [key key] :command <command_options>
<mod> is what we call a "modifier" and you can use 'xmodmap -pm' from the command-line to see what modifiers are available. Typical modifiers to be use in the keys file are:
Mod1 == Alt Mod4 == Windows key Control == Ctrl Shift == Shift
If you want to find out the name of a key, open a terminal and run 'xev'. When the "Event Tester" window has focus, it will capture mouse movement, mouse clicks, and keypress events, then provide output in the terminal. If a key you want to use has no name, you can use its keycode and Fluxbox will still understand.
Here are a few examples:
Control i :ExecCommand xterm # Ctrl+i will bring up an xterm Mod4 4 :Workspace 4 # Windowskey+4 will change to workspace 4 None F12 :ExecCommand firefox # F12 will start Firefox Control Mod1 r :exec fbrun # Ctrl+Alt+r will bring up the Fluxbox command dialog Mod1 Shift F4 :KillWindow # Alt+Shift+F4 kills the focused window Mod1 113 :exec xterm # Just to show the keycode usage
A basic, common command is ExecCommand, or Exec if you like it shorter. You can execute apps, scripts (take care of $PATH), set things via 'xset' and so on with it.
Some things to know
- Commands are case-insensitive
- Workspace numbering starts at 1
- Some commands have synonyms
- The space between the last key and the ":" is mandatory.
Fluxkeys
Caution: Currently the fluxkeys utility is out of date and will break your ~/.fluxbox/keys file.
Mouse Events
Since SVN r4704, Fluxbox now handles mouse events in the keys file. (details)
Figuring out the name of a mouse event is similar to figuring it out for a key. Just run 'xev' like before and use the button/wheel in the "Event Tester" window. It usually returns a "Mouse##" identifier, where ## is the number of the button. Mouse buttons also add a new modifier called OnDesktop, which makes the mouse event only trigger if it's on the desktop (AKA root window). This only works with mouse buttons and has to be called before each mouse event that wants to be triggered only on the root window.
For example, the typical Fluxbox behavior of mouse wheel up/down on root window to change desktop would be:
OnDesktop Mouse4 :nextWorkspace OnDesktop Mouse5 :prevWorkspace
You can also keychain mouse events.
If your keys file didn't get updated automatically, the default behaviour comes with following:
OnDesktop Mouse1 :hideMenus OnDesktop Mouse2 :workspaceMenu OnDesktop Mouse3 :rootMenu OnDesktop Mouse4 :nextWorkspace OnDesktop Mouse5 :prevWorkspace
Keychains
Fluxbox can handle keychains in a similar way to emacs. For example:
Control n Mod1 n :Close # ctrl+n alt+n will close the focused window None F11 F12 :ExecCommand ssh example.com # F11 F12 runs 'ssh'
Note that to use a keychain without modifiers, "None" should only be used once. "None F11 None F12" will not work. Use "None F11 F12" as shown above instead.
Fluxbox Keycommands
There are plenty of internal commands to make life easier. Use them the same way as above just exchange the Exec[Command] part with the one you want to use.
Window Manager Commands
Restart <argument> # Restarts fluxbox, argument can be the binary of another window manager to which will be switched Quit # Exits Fluxbox Exit # Exits Fluxbox Reconfigure # Reloads the config Reload Style # Reloads the style if any files were changed SetStyle <argument> # Sets a specific style. useful for a standard style for testing purposes ExecCommand <argument> # Executes a command. look above for what the argument can be Exec <argument> # Executes a command. look above for what the argument can be
Currently Focused Window Commands
Fullscreen # Makes the focused window fullscreen covering all components, even if they are set to a higher layer Minimize # Minimizes the focused window. equivalent to the windowbutton MinimizeWindow # Minimizes the focused window. equivalent to the windowbutton Iconify # Minimizes the focused window. equivalent to the windowbutton Maximize # Maximizes the focused window. equivalent to the windowbutton MaximizeWindow # Maximizes the focused window. equivalent to the windowbutton MaximizeHorizontal # Maximizes the focused window horizontally MaximizeVertical # Maximizes the focused window vertically ResizeTo <width> <height> # Resizes the focused window to the specified values Resize <delta-width> <delta-height> # Scroll down for some further information on this command ResizeHorizontal <delta-width> # Scroll down for some further information on this command ResizeVertical <delta-height> # Scroll down for some further information on this command MoveTo <x> <y> <ref corner> # Scroll down for some further information on this command Move <delta-x> <delta-y> # Scroll down for some further information on this command MoveRight <delta-x> # Scroll down for some further information on this command MoveLeft <delta-x> # Scroll down for some further information on this command MoveUp <delta-y> # Scroll down for some further information on this command MoveDown <delta-y> # Scroll down for some further information on this command Raise # Raises the focused window RaiseLayer # Raises the focused window one layer Lower # Lowers the focused window LowerLayer # Lowers the focused window one layer Close # Closes the focused window. same as the windowbutton Shade # Shades the focused window. same as the windowbutton ShadeWindow # Shades the focused window. same as the windowbutton Stick # Makes the focused window sticky/unsticky. same as the windowbutton StickWindow # Makes the focused window sticky/unsticky. same as the windowbutton ToggleDecor # Makes the focused window borderless SendToWorkspace <number> # Sends the focused window to the workspace given by number SendToNextWorkspace <number> # Sends the focused window to the next workspace given by number SendToPrevWorkspace <number> # Sends the focused window to the previous workspace given by number TakeToWorkspace <number> # Sends the focused window to the workspace given by number and switches the view to it TakeToNextWorkspace <number> # Sends the focused window to the next workspace given by number and switches the view to it TakeToPrevWorkspace <number> # Sends the focused window to the previous workspace given by number and switches the view to it KillWindow # Kills the focused window NextTab # Switches to the next tab of the focused window PrevTab # Switches to the previous tab of the focused window MoveTabLeft # Moves the focused tab to the left MoveTabRight # Moves the focused tab to the right DetachClient # Detaches the focused tab from a group SetHead <int> # Sets the default head for a window --> xinerama FocusUp # Sets the focus to the window north of the focused one FocusDown # Sets the focus to the window south of the focused one FocusLeft # Sets the focus to the window west of the focused one FocusRight # Sets the focus to the window east of the focused one
Workspace Commands
NextWorkspace <by-number> # Switches "number" workspaces to the right PrevWorkspace <by-number> # Switches "number" workspaces to the left RightWorkspace <by-number> # Switches "number" workspaces to the right without wrapping around LeftWorkspace <by-number> # Switches "number" workspaces to the left without wrapping around Workspace <number> # Switches to the workspace given by number NextWindow <bitmask> # Scroll down for further information PrevWindow <bitmask> # Scroll down for further information NextGroup <bitmask> # Same as NextWindow but cycles through groups only PrevGroup <bitmask> # Same as PrevWindow but cycles through groups only ArrangeWindows # Arranges windows :) ShowDesktop # Iconifies all windows of the current workspace RootMenu # Pops up the right-click menu WorkspaceMenu # Pops up the middle-click menu WindowMenu # Pops up the windowtitle menu SetWorkspaceName <name> # Renames the current workspace Deiconify <mode> <dest> # Restores minimized windows
Special Commands
MacroCmd #scroll down for further information ToggleCmd #scroll down for further information ReloadStyle #reloads the style SetResourceValue <rc_name> <resource> value #to be done...no one will ever need this! BindKey <key><value>: <action> #creates an "on the fly" keycommand
Explanation
- TakeToWorkspace will send you along with the window to the selected workspace. SendToWorkspace just sends the window.
- PrevWindow/NextWindow parameters take a bitmask:
- 0 or unspecified = Default/current behavior - no skipping
- 1 cycle groups
- 2 skip stuck windows
- 4 skip shaded windows
- 8 cycle linear (use the same order every time)
For example, the following will skip any window that's, stuck or shaded since 6 = 4 + 2.
Mod1 tab :NextWindow 6
- Deiconify has options for which windows to deiconify and which workspace they should be restored to.
- mode: All | AllWorkspace | Last | LastWorkspace
- dest: Current | Origin
- BindKey will append key string and action to your keys file and bind the key.
- A delta value means the difference between the current setting and the requested setting. Assume your window 100 is pixels wide.
Mod1 r :ResizeHorizontal 10
When you use that key it would increase the size of your window to 110 pixels. If you had used the following command, it would have decreased the size by 10, setting it to 90 pixels.
Mod1 R :ResizeHorizontal -10
- The syntax of the MoveTo command is the following:
:MoveTo [int|*] [int|*] [reference corner]
The wildcard * means "use current value" and 'reference corner' is one of the following:
- Left, Right
- Upper, UpperLeft, UpperRight
- Lower, LowerLeft, LowerRight
Examples:
:MoveTo 0 * Left -> snap to left workspace edge :MoveTo * 0 Lower -> snap to lower workspace edge :MoveTo 0 0 UpperRight -> snap to upper right workspace corner
MacroCmd Syntax
Mod1 r :MacroCmd {command1} {command2} {command3}...
MacroCmd allows you to execute more than one command with a single keybinding. The commands given to MacroCmd will be executed in the order they are supplied, and can be either Exec[Command] or internal commands such as ShowDesktop.
Example:
Mod1 u :MacroCmd {Moveto 10 5} {ResizeTo 1260 590}
Mod1 o :MacroCmd {MoveTo 10 600} {ResizeTo 1250 380}
The first command could be used to move and resize your browser to the upper corner of the screen, while the second could be used in a terminal windows, to move and resizes it below.
ToggleCmd Syntax
Mod1 t :ToggleCmd {command1} {command2}
This alternates between the given commands each time you press Mod1 + t. For example, you could use ShowDesktop and DeIconify all originquiet. The command to make Windows-key + m minimize all windows, and then bring them back is:
Mod4 m :ToggleCmd {ShowDesktop} {DeIconify all originquiet}
Combining ToggleCmd and MacroCmd
<mod> <key> :ToggleCmd {MacroCmd {<command_1>} {<command_2}} {MacroCmd {<command_1>} {<command_2}}
ToggleCmd and MacroCmd can be used in unison in order to use one keybinding for two macros. It's an advanced way to use keys, but it may not be of any value to you. Be creative and see what you can come up with.
Using wmctrl
Fluxbox promotes minimalistic usage, and to keep in-line with this approach, you can use wmctrl to prevent more than one instance of an application to be open.
Check if you have wmctrl installed
which wmctrl
If it is installed, you will be presented with the path, if not, you will be told. If not please install using your distrobution's package install method.
Save the script below as 'find_app.sh' (anywhere in your filesystem)
#!/bin/bash
# Find_app
# Author: Lucas van Staden (lvs at softhome.net)
# This little script will try and find the application attempting to start
# in the running processes, and if found, focus the application
# if not found, a new instance will start
# usage:
# find_app.sh <application with full path>
# params
# 1 - application to start (full path)
# helper applications
WMCTRL=`which wmctrl`;
GREP=`which grep`;
APPLICATION=$1;
BASENAME=`basename $APPLICATION`;
BASENAME=`echo $BASENAME | tr "[:upper:]" "[:lower:]"`
FOUND=0;
function findwindow {
# 1 = BASENAME
# 2 = WMCTRL
# 3 = GREP
IFS=$'\n';
for RUNNING in `$2 -l -x`
do
if [ `echo $RUNNING | tr "[:upper:]" "[:lower:]" | $3 -c $1` -gt 0 ]
then
HOSTNAME=`hostname`
WINDOW=${RUNNING#*${HOSTNAME} }
$2 -a $WINDOW
FOUND=1;
fi;
done
}
findwindow $BASENAME $WMCTRL $GREP;
if [ $FOUND -eq 0 ]
then
$APPLICATION
sleep 2;
findwindow $BASENAME $WMCTRL $GREP;
if [ $FOUND -eq 0 ]
then
sleep 3;
findwindow $BASENAME $WMCTRL $GREP;
fi
fi
Make sure the script is executable
chmod +x find_app.sh
Now in your keys file, in place of calling the application directly, use the wrapper script above, for example the following line in the keys file
Control Mod1 f :ExecCommand ~/.fluxbox/scripts/find_app.sh /usr/bin/firefox
will try and start firefox, but if firefox is already running, then it will be set as the active, top-most application, and you will be moved to the desktop where it is running. If firefox is not running, it will be started as usual, and after a short delay, you will be moved to the desktop where it started up.
You can now use the keypress, not just to start an application, but to find an open instance.

