Customizing keyboard shortcuts in Fluxbox
Out of the box, Fluxbox provides only the most basic keyboard shortucts for
flipping through your applications and workspaces. Fortunately, Fluxbox
includes a simple but efficient way of customizing your keyboard shortcuts
for managing your desktop and applications.
The fluxbox keys file
Inside your fluxbox directory (.fluxbox), there is a file with the name keys. By default, mine looked like this:
Mod1 Tab :NextWindow Mod1 Shift Tab :PrevWindow Mod1 F1 :Workspace 1 Mod1 F2 :Workspace 2 Mod1 F3 :Workspace 3 Mod1 F4 :Workspace 4 Mod1 F5 :Workspace 5 Mod1 F6 :Workspace 6 Mod1 F7 :Workspace 7 Mod1 F8 :Workspace 8 Mod1 F9 :Workspace 9 Mod1 F10 :Workspace 10 Mod1 F11 :Workspace 11 Mod1 F12 :Workspace 12
Now, Mod1 is your alt key, so this file says that you can flip
through your windows (backward and forward) with alt-tab and alt-shift-tab.
This is just like on any operating system. Alt-Fn (n from 1 to 12) takes you to
the workspace with the corresponding number. You probably have 4 workspaces by
default so the last 8 doesn’t do anything.
Your first customized keyboard shortcut
One common task is to minimize a window (or iconize as it’s also called).
To avoid clashes with application shortcuts, the ctrl-alt combination can be
used as a namespace
for your shortcuts. Add the following line to your kes file (below the current content):
Mod1 Control i :Minimize
To make Fluxbox aware of this new keyboard shortcut, save your keys file and
reconfigure Fluxbox by right clicking on an empty area on your desktop and select Reconfigure
from the menu. You can now press ctrl-alt-i to
minimize the current window.
A trick to ease your experiments
The whole point of this is to enable more efficient use of your keyboard and
less mouse usage. So to make your keyboard experiments 100% keyboard-driven
you should be able to reconfigure fluxbox with a keystroke. The command for
this is of course called Reconfigure
and I have chosen to bind this to
ctrl-alt-r. The following line in my keys file enables that:
Mod1 Control r :Reconfigure
Now you can just save your keys file and press ctrl-alt-r to test your configuration. You can test this by binding Minimize to a different key.
Controlling the Audacious media player
With the ExecCommand directive, you can bind regular commands that you would
normally type in a shell to keyboard combinations of your choice. One
application that is controllable from the command line is Audacious, an
uncomplicated audio player forked from Beep Media Player which was forked
from XMMS a long time ago. So we should be able to control Audacious with some simple keystrokes.
Starting Audacious
Most keyboards have a so-called Windows key that can be quite useless if you
are using Linux. This also means that it won’t clash with application shortcuts
and I think it is a good choice for binding to your favorite applications.
This key is also called the super key, so to avoid the w-word, we’ll go for that name.
The super key is called Mod4 within Fluxbox, so the line in your keys file for
starting Audacious on pressing super-a is:
Mod4 a :ExecCommand audacious
Controlling Audacious
By typing man audacious in your shell you will find out that you
can control Audacoius from the command line with the following commands
(explanations):
audacious -r (rewind/previous track) audacious -p (play) audacious -u (pause) audacious -s (stop) audacious -f (forward/next track)
These are bound to the keys z, x, c, v and b inside Audacious so we will use
those instead. For controlling applications, I have chosen the prefix
ctrl-super. The key a is then used as a prefix for Audacious. So the
following is found in my keys file:
Mod4 Control a Mod4 Control z :ExecCommand audacious -r Mod4 Control a Mod4 Control x :ExecCommand audacious -p Mod4 Control a Mod4 Control c :ExecCommand audacious -u Mod4 Control a Mod4 Control v :ExecCommand audacious -s Mod4 Control a Mod4 Control b :ExecCommand audacious -f
Reconfigure Fluxbox, and you can start and control Audacious from your keyboard
without locating the Audacious windows on your desktop. Just type
super-a for starting Audacious, ctrl-super-a x for
playing your selected track (hold down ctrl and super, type a, then x before
releasing ctrl-super). Just type ctrl-super-a b to skip to the
next track in your playlist and so on…
This was done with a fully updated Sidux Linux, Fluxbox 0.9.14 and Audacious 1.2.2. I hope it works on your setup too. You can also see my current keys file (which may or may not be updated in the future) and check out the official documentation on the subject of key bindings.