Adventures in Linux: Keys to Fluxbox Keys
Last Updated on February 24, 2024 11:19 am by Jeffrey Powers
I have often mentioned my preference for Fluxbox as a window manager for my Linux machines. It’s small, light, and fast, and does everything I want.
Lately, I have been perfecting my Fluxbox keys file, which manages key bindings (also known as hot keys). Windows users are commonly familiar with a few Windows hotkey combinations, such as
- ALT-F4 to close a window, or, if no windows are open, exit Windows.
- ALT-Tab to move from one open window to another.
- CTRL-Esc to display the menu.
- CTRL-x to cut highlighted items, such as text.
- CTRL-c to copy highlighted items.
- CTRL-v to paste the most recent item from the clipboard.
Fluxbox gives me many more hotkeys out-of-the-box (most of which I don’t use), plus the ability to easily reconfigure my keys file, which, like all Linux configuration files, is a plain text file.
Creating a keybinding is easy. You have to know
- What commands you wish to have hotkeys,
- How to launch the command from the command line,
- What key bindings are already in use (easily determined by looking over the keys file).
- What key combination you wish to use for the hotkey combination.
I test a command from the command line before I put it in keys file. Next I put it in the keys file. Then I restart Fluxbox to test it and correct any errors before exiting the editor. (Fluxbox conveniently contains a “Restart” command which causes Fluxbox to re-read its configuration files without disturbing any running programs.) Command line switches may be included in the keybinding.
Here’s the keys I have added to my keys file; everything in the list is a frequently-used program:
#Added by Frank
Mod4 c :ExecCommand gnome-calculator
Mod4 e :ExecCommand gedit
Mod4 f :ExecCommand iceweasel
Mod4 k :ExecCommand konqueror ~
Mod4 m :ExecCommand icedove
Mod4 n :ExecCommand nautilus –no-desktop –browser
Mod4 o :ExecCommand opera
Mod4 t :ExecCommand gnome-terminal
Mod4 v :ExecCommand gnome-volume-control
Mod4 w :ExecCommand oowriter
Control Escape :RootMenu
Mod1 q :exit
Mod1 refers to the ALT key; Mod4 to the “Super_L” key (the one that has a Windows logo on it on most computers).
Since I don’t always have the same program on each computer, I have developed these conventions for my own convenience:
- m for the email client,
- t for the terminal emulator program, and
- e for the text editor.
I’ll parse this command:
Mod4 n :ExecCommand nautilus –no-desktop –browser
Pressing “n” while holding down the “Windows” key launches Nautilus in file manager mode. (Without the switches, Nautilus would take over my desktop, thinking I was running the Gnome desktop environment; this would result in replacing the right-click to activate the Fluxbox menu with Nautilus’s right-click to open the context-sensitive desktop configuration menu).
Any program must be in your path (by default, they usually are) and the program name must be preceded by “ExecCommand.” An internal Fluxbox command, such as “Rootmenu” to display the menu or “Exit” to quit Fluxbox does not.
I find it especially useful because, if my desktop is cluttered with open windows, I don’t have to hunt around for a place to right-click to open the menu; I can just hit the appropriate hotkeys.
The Fluxbox keys file is located in the dot fluxbox directory (the “dot” means it is a hidden folder) in a user’s home folder (that is /home/[username]/.fluxbox, roughly equivalent to C:\Documents and Settings\[username] in Windows).
Here’s the contents of my /home/[username]/.fluxbox directory (the files with the tilde ~ after them are backups created by text editors when I edit a file):
dir ~/.fluxbox
apps init keys lastwallpaper menu~ overlay~ slitlist startup~ backgrounds init~ keys~ menu overlay pixmaps startup styles
To ensure consistency across my computers, I can copy the keybindings from the keys file, paste them into an email, and email them to myself so I can just paste them into the keys files on my other computers, then tweak the settings appropriately. For example, “Iceweasel” and “Icedove” are the Debian versions of “Firefox” and “Thunderbird”; on my Ubuntu computer, I would change “iceweasel” to “firefox” and “icedove” to whatever email client I’m using on that computer (I’ve been playing around with using different clients on different computers just because I can).
You can read more about Fluxbox keys here. Klaatu got me started learning how to do this in Episode 5×06 of his podcast.