Configuring Fluxbox Shortcut Keys!
July 24th, 2008 Pekk Posted in Linux |
Hey! I’m back already! Did you miss me? Probably not, but I do have some very useful news! I’ve just discovered how to set up keyboard shortcuts on Fluxbox. Although it is very easy the only reason I’m writing this short article is because I was have some slight issues trying to get Fluxbox to recognize my ; and ‘ keys in the ~/.fluxbox/keys file. So here’s a short guide on how to add shortcut keys on to your fluxbox.
If I didn’t already disclose it to you directly enough the file you’ll be editing is ~/.fluxbox/keys and mine looks something like this:
OnDesktop Mouse1 :HideMenus
OnDesktop Mouse2 :WorkspaceMenu
OnDesktop Mouse3 :RootMenu
OnDesktop Mouse4 :NextWorkspace
OnDesktop Mouse5 :PrevWorkspaceMod1 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
Just from looking at the file it’s not too hard to tell what’s going on here. The file appears in the format:
Key Code Combination :command
From what I’ve read the space before the semicolon is important otherwise your commands won’t work. You can put any keys here with any modifiers. To get a list of your currently mapped modifier keys use the xmodmap utility, and it will give you some output, for example:
(73) .fluxbox/ $ xmodmap
xmodmap: up to 3 keys per modifier, (keycodes in parentheses):shift Shift_L (0×32), Shift_R (0×3e)
lock Caps_Lock (0×42)
control Control_L (0×25), Control_R (0×6d)
mod1 Alt_L (0×40), Alt_L (0×7d), Meta_L (0×9c)
mod2 Num_Lock (0×4d)
mod3
mod4 Super_L (0×7f), Hyper_L (0×80)
mod5 Mode_switch (0×5d), ISO_Level3_Shift (0×7c)
If this seems confusing to you let me explain–if you want to use the ctrl key (according to what my xmodmap output says) I would use control, for example if I wanted Ctrl + Tab to switch to next workspace I could do:
Control Tab :NextWorkspace
And to make Control + Shift + Tab go backwards (which would make sense):
Control Shift Tab :PrevWorkspace
(The name of your modifier key is the output of the first column from xmodmap) if you’re still not sure exactly which column to read (for whatever the reason may be) it may be easier to read the output of the following command:
xmodmap |cut -d ‘ ‘ -f 1
Which, for me (following the same output I had above) would now give us this new output:
(87) .fluxbox/ $ xmodmap |cut -d ‘ ‘ -f 1
xmodmap:shift
lock
control
mod1
mod2
mod3
mod4
mod5
For a list of more commands you can hotkey, check out the commands listed at the fluxbox wiki keyboard shortcuts page
Now for most of you, you should be pretty satisfied with what you’ve learned so far. But for me, of course this wasn’t enough. Why? Because I couldn’t figure out for the life of me how to get fluxbox to recognize my damed ; and ‘ keys! Then
as I searched the net more and more thoroughly I came across a wonderful solution: xev
Using the xev command we are able to view key strokes and their names (along with other miscellaneous x events. So I fire up my xev (it gives a whole bunch of output from startup) and when it’s ready I hit my ; key. The output (after releasing the ; key) looks something like this:
KeyPress event, serial 32, synthetic NO, window 0×1200001,
root 0×3f, subw 0×0, time 1480794821, (602,218), root:(654,288),
state 0×0, keycode 47 (keysym 0×3b, semicolon), same_screen YES,
XLookupString gives 1 bytes: (3b) “;”
XmbLookupString gives 1 bytes: (3b) “;”
XFilterEvent returns: FalseKeyRelease event, serial 32, synthetic NO, window 0×1200001,
root 0×3f, subw 0×0, time 1480795069, (602,218), root:(654,288),
state 0×0, keycode 47 (keysym 0×3b, semicolon), same_screen YES,
XLookupString gives 1 bytes: (3b) “;”
XFilterEvent returns: False
What we’re looking for here is what comes after the keycode i.e., (keysym 0×3b, semicolon) in this example. The same process can be used for any key. So now I’ve added the following to my fluxbox keys file at the bottom:
#Greg’s Custom Mods
#Workspaces—————–
Control Shift J :Workspace 1
Control Shift K :Workspace 2
Control Shift L :Workspace 3
Control Shift semicolon :Workspace 4
Control Shift apostrophe :Workspace 5
#moving windows to specific workspaces
Control Mod1 Shift J :SendToWorkspace 1
Control Mod1 Shift K :SendToWorkspace 2
Control Mod1 Shift L :SendToWorkspace 3
Control Mod1 Shift semicolon :SendToWorkspace 4
Control Mod1 Shift apostrophe :SendToWorkspace 5#Programs——————-
Control Shift I :Exec xterm
Control Shift O :Exec firefox#Windows——————–
Mod1 W :Close
Mod1 Shift M :Maximize
Mod1 Shift N :ToggleDecor
More will come later! Good luck and happy flux-ing!
Leave a Reply