Page 1 of 5 123 ... LastLast
Results 1 to 10 of 50

Thread: HOWTO: The power of Fluxbox keys

  1. #1
    Join Date
    Feb 2007

    HOWTO: The power of Fluxbox keys

    This how-to is all about discovering the power of key binding in Fluxbox, helping you understand the syntax and possibilities, and providing a wealth of examples to wet your appetite. I hope that it will entice those who never really thought much about using fluxbox's keys to give it a shot. In my best attempt at encouraging you to use fluxbox keys, I've even included a sample keys file below with just about every flavor key-binding possible (including many of the examples in this how-to) so you can start playing around straight away.

    All of the text below is based on V1.0 of Fluxbox. However, most of this should work with previous versions. If you want to upgrade to V1.0 (which has fixes to numerous bugs related to key binding) and its not in the repository, please check out Red Squirrel's how-to for compiling fluxbox from source. This how-to has been tested on Edgy, but should work for all versions of Ubuntu.

    The driving force for this how-to came about after discovering that there are many users out there who have never modified their 'keys' file, which is a crying shame! Also, while the existing documentation out there is very thorough, its a bit like a dictionary. Great for reference, but not so great on how to build useful sentences with all those words.

    Table of contents:
    1. Why use keys?
    2. The basics and simple examples
    3. How to identify keys on your keyboard (and mouse)
    4. More advanced examples and inspiration.
    5. Common Mistakes/Gotcha's/Troubleshooting
    6. Further info/Credits

    1) Why use keys?

    Quite simply, because its *so* fast and provides a level of power and customization not possible otherwise. Mastering fluxbox's keys file will enhance your user experience and give you a raft of tools and actions not easily achievable through other methods, while still keeping fluxbox light and fast. Using keys in a windowing environment is akin to using the CLI (Command Line Interface, aka Terminal). Its not technically necessary most of the time and it has a definite learning curve (since you have to teach yourself to use the key-combination and not the mouse). However, the trade-off is that you can often do things a lot more easily and quickly with keys. Some things (such as CustomMenu) just can't be reproduced easily (or even at all) through other methods. Oh, and there's a definite cool-factor too

    Use Firefox all the time? Traditionally, people store a quick-launch icon on their toolbar, or a shortcut on their desktop to launch Firefox (or other app). Or perhaps you've modified your menu file so that when you right-click on the desktop 'Firefox' appears in the root menu. Not to bad, but thinking semantically, you have to get to your mouse, move the mouse pointer and concentrate and aim for the icon or menu item and click. If your fluxbox setup doesn't have a desktop manager (e.g. default fluxbox) you have to go even further by finding a free bit of desktop to right click on to get your menu. These icons, desktop shortcuts and menu items also have the downside of unnecessary 'clutter' which is arguably against the Fluxbox philosophy of light-weight, simple and fast.

    Faster, simpler and more minimalistic is to bind a key combination, such as Mod4-f (Mod4 is the windows key), to launch Firefox. Pressing these two keys will launch Firefox. No icons needed, no menu items required and if you can touch-type, no concentration needed either.

    With the right key bindings you can do away with menus, icons, toolbars and window titlebars if you wanted, leaving you with a workspace consisting of your (optional!) background image only and still be more productive than your desktop/icon/menu/mouse bound friends.

    But launching applications is just the beginning. You can do much more with keys...

    2) The basics and simple examples

    Right, enough yaking. First things first. Backup your existing keys file:
    cp ~/.fluxbox/keys ~/.fluxbox/keys.backup
    All Fluxbox key bindings are by default stored in ~/.fluxbox/keys. Lines in this file beginning with a # or ! are considered comments and ignored by fluxbox. Any changes to the keys file requires you to reconfigure fluxbox. The easiest way to do this is via your root menu which should have a 'Reconfigure' option in there. Alternatively, you can use the following from the command line:

    kill -s USR2 `xprop -root _BLACKBOX_PID | awk '{print $3}'`
    The basic format of this file is as such:
    <mod> [<mod> <mod>] key :command <operation>

    Where <mod> is a modifier such as the Control (Ctrl), Windows (usually located between the control and alt keys), or Alt keys (often known to the fluxbox keys file as 'Control', 'Mod4' and 'Mod1' respectively) and <key> is a normal key ('f', '3', 'F6', etc.).

    <mod> itself is optional, in which case the 'None' keyword is used (e.g. None F12 :Exec someProgram)

    Control Mod4 f :Exec firefox
    You can also assign multiple key sequences for actions (press Mod4 e, then Mod4 F1). It is the complete sequence which launches Firefox here.
    Mod4 e Mod4 F1 :Exec firefox
    Thing you can assign to keys:

    - Window commands
    Allows you to do pretty much anything the window menu can do (e.g. the right-click menu on the window title-bar) with more control. Think move, resize, minimize, maximize, shade, close, etc. See this part of the fluxbox wiki for a full list of window commands. A few samples:
    #The 'Close' command will close the active window.  The 'Fullscreen' key binding will toggle the window between its current and fullscreen state
    Mod4 F4	 		:Close                               
    Control Mod1 f	:Fullscreen
    - Fluxbox commands
    Commands specific to fluxbox such as "Restart", "Reconfigure" and "ReloadStyle". See this part of the fluxbox wiki for a full list of fluxbox commands.
    #'Restart' will restart fluxbox.  'RootMenu' will pull up the root menu (e.g. what you get when you right-click on the desktop)
    Mod4 Shift r	 :Restart 
    Mod4 Shift m	 :RootMenu
    - Shell executable commands (programs, scripts, etc.). These take the format of "<mod> <key> :Exec command". Or the verbose "<mod> <key> :ExecCommand <command>"
    where '<command>' is anything you can execute on the terminal command line.
    #Launches Firefox
    MOd4 f			:Exec firefox
    #Creates a backup of your keys file
    Mod4 i    		:Exec cp ~/.fluxbox/keys ~/.fluxbox/keys.backup
    - Workspace commands
    Allows you to do pretty much anything the workspace menu can do (e.g. the middle click menu on the desktop). See this part of the fluxbox wiki for a full list of workspace commands
    #Jump to workspace 2
    Mod4 2	 		 :Workspace 2
    #Minimize all windows on the current workspace
    Control Mod4 s	 :ShowDesktop
    - Special commands
    Unique stuff like Marco (one key biding to multiple actions), Toggle (one key binding to two actions, toggling between them). See this part of the fluxbox wiki for a full list of special commands
    #Move AND resize the window
    Control Mod1 r 	 :MacroCmd {MoveTo 15 15} {ResizeTo 1115 810} 
    #Swap back and forth between 2 different sizes for the current window, anchored at the top left corner
    Mod4 d 		 	 :ToggleCmd {ResizeTo 557 405} {ResizeTo 1115 810}
    Finally, there is a utility called 'fluxkeys' which will 'help' build a keys file. BEWARE: This program will corrupt your keys file changing any desktop mouse binding to 'Mousetop1' 'Mousetop2', etc. Doing this will disable your ability to correclty use your mouse properly, which can be a real hinderance in Fluxbox if your other keys don't work yet. Also, be aware that when you save your changes with fluxkeys, it will remove any comments and blank lines from your keys file. Additionally, any command which fluxkeys doesn't recognize is removed from your keys file. This includes keymodes, custom menus and others.. It also appeared to have truncated my keys file removing a large chunk at the end of my file. My advice is to stay away from this program and build your keys file in a text editor (nano, kate, gedit, etc.).

    3) How to identify keys on your keyboard (and mouse)

    identify key names with 'xev'. From a console, enter 'xev' on the command line. This will then output to the screen any key events (Press, release, hold, etc) and mouse events. Control-c quits 'xev' (or close the little white window). We're interested in the key events. To find out the name of the key to use in the keys file, simply press the key you are interested in which will output event info to the terminal window. In the example below, I pressed the multimedia back arrow key on my keyboard and got the following output:
    	KeyRelease event, serial 32, synthetic NO, window 0xc00001,
        root 0x45, subw 0x0, time 4196058985, (353,248), root:(386,303),
        state 0x10, keycode 234 (keysym 0x1008ff26, XF86Back), same_screen YES,
        XLookupString gives 0 bytes:
        XFilterEvent returns: False
    The important bits here are the "keycode 234 (keysym 0x1008ff26, XF86Back)" which uniquely identifies the key. There are two ways we can identify the above key. The first is the numeric keycode (234 in this case), or the key literal (XF86Back). So, to assign this key to Firefox, we would use one of the following:
    None 234 		:Exec firefox
    None XF86Back	:Exec firefox
    Note that some keys won't show up properly in xev if you've already got them bound in the keys file.

    identify modifiers with 'xmodmap -pm'. As you can see from the output of my 'xmodmap -pm' below, I have 8 modifiers. From one of the fluxbox developers: "Fluxbox ignores any modifier containing num_lock or scroll_lock, and it also ignores the lock modifier, (although if caps_lock is bound to another modifier, like Mod3, it can be used)". This leaves 5 usable ones. Super_L (Mod4) is that Windows key found between the Ctrl and Alt keys. ISO_Level3_Shift is labeled 'Alt Gr' on my keyboard and is located just to the right of my space bar.

    xmodmap:  up to 3 keys per modifier, (keycodes in parentheses):
    shift       Shift_L (0x32),  Shift_R (0x3e)
    lock        Caps_Lock (0x42)
    control     Control_L (0x25),  Control_R (0x6d)
    mod1        Alt_L (0x40),  Alt_L (0x7d),  Meta_L (0x9c)
    mod2        Num_Lock (0x4d)
    mod4        Super_L (0x7f),  Hyper_L (0x80)
    mod5        Mode_switch (0x5d),  ISO_Level3_Shift (0x71),  ISO_Level3_Shift (0x7c)

    For more information or help in setting up your multimedia keyboard, check out this very useful website:

    Many mice these days have '5' buttons. That is, they have 2 primary buttons and a mouse wheel as follows:
    Mouse1 = left click
    Mouse2 = middle click (e.g. mouse wheel click)
    Mouse3 = right click
    Mouse4 = mouse wheel up
    Mouse5 = mouse wheel down

    Here's the output of 'xev' with mouse clicks:

    ButtonPress event, serial 32, synthetic NO, window 0x1a00001,
        root 0x45, subw 0x0, time 475499353, (92,108), root:(693,462),
        state 0x10, button 5, same_screen YES
    This identified a mouse wheel down event (button 5), but is known to the keys file as Mouse5.

    4) More advanced examples and inspiration.

    Right. Enough of the basics which are well covered elsewhere. Lets look at some more useful and diverse examples.

    -Audio. Use your keyboard to control the master volume.
    #Volume.  Will lower or raise volume by 5%.  The third key binding will toggle mute.
    None XF86AudioLowerVolume       :Exec amixer sset Master,0 5%-
    None XF86AudioRaiseVolume       :Exec amixer sset Master,0 5%+
    None XF86AudioMute              :Exec amixer sset Master,0 toggle

    Most music players support command line interaction. Some provide quite a rich command line interface allowing you to create a customized command only interface to do most things the music player GUI could have done.
    #Amarok.  '-f' will forward one track. '-r' will reverse one track. '--pause' will toggle playback pause
    #XMMS.	  'xmms -f' will forward one track. 'xmms -r' will reverse one track. 'xmms -t' will toggle pause/play. 'xmms -s' will stop.    
    Mod4 Control Right              :Exec amarok -f
    Mod4 Control Left               :Exec amarok -r
    Mod4 Control Down               :Exec amarok --pause
    -On screen text display (and visually displaying volume changes)
    'osdsh' is a little daemon which allows you to write text to an unshaped, unmanaged window on the desktop. Think super-basic conky. The effect is similar to TV volume/channel change updating on the screen in green text. This utility has the ability to automatically monitor changes to the amixer Master volume and dynamically display a volume bar on your screen when it changes. It can also display a clock or any two lines of text, really. osdsh is controlled by the ostctl utility which can also start other monitoring daemons, including one for monitoring laptop batteries. The 'osdshconfig' utility will allow you to set a theme/style to your text and control other aspects like position and color.

    To install (if required, you may already have this):
    sudo aptitude install osdsh
    Then create the following script to add to your fluxbox startup file. Don't forget to change it to executable (chmod a+x <scriptname>).
    #Load the daemon
    #give it time to start
    sleep 1
    #Load a style/theme. Optional.  This is my theme and does NOT come with osdsh, so it will need changing to your own custom theme if you want to use one.
    osdctl -S ~/.osdTheme
    osdctl -m 1
    Then modify ~/.fluxbox/startup to include this script. Make sure to put this before the fluxbox command at the bottom and don't forget to do this in the background (i.e. append '&' to the end of the script name).

    Once osdsh is running, entering
    osdctl -s "Your text here"
    will output the text to the screen.

    To display a second line of text, add a ',' to separate the two lines (e.g. "Your text,here"). There's also a small bug which sometimes displays random text on the second line (if you've only specified one line of text). To get around this, use osdctl -s "text to display," forcing a blank second line.

    Note that there appears to be an issue using the various daemons (volume and battery) in Gutsy Gibbon, though they work fine in Edgy Eft. I haven't fully confirmed this yet, so keep an eye on your CPU if you use those. Here's a workaround for the volume daemon so you can still get the same effect (where keys 160, 174 and 176 are my mute, volume down and volume up keys respectively):
    None 160       :ToggleCmd {Exec amixer sset Master,0 toggle && osdctl -s "Mute on"} {Exec amixer sset Master,0 toggle && osdctl -s "Mute off"}
    None 174	:Exec osdctl -b "Master Volume",$(amixer sset Master,0 5%-|grep "Front Left:"|cut -d "[" -f2|cut -d "%" -f1)
    None 176	:Exec osdctl -b "Master Volume",$(amixer sset Master,0 5%+|grep "Front Left:"|cut -d "[" -f2|cut -d "%" -f1)
    And here's a way to show battery power without the battery daemon:
    osdctl -b "Battery Power",$(acpi|cut -d "," -f2|cut -d "%" -f1|cut -d " " -f2)
    -show date and time - great if you don't use a panel or the slit for a clock
    Mod4 KP_5					:Exec osdctl -s $(date)
    #or define a date/time format for osdctl and use this instead.  2 is the number of seconds to show the clock.
    Mod4 KP_6					:Exec osdctl -t 2
    What else can this program do for your keys file? Consider using it for visual feedback. Reconfiguring fluxbox provides no visual feedback that its actually done anything, so how about this:
    Mod4 Escape		 		 :MacroCmd {Exec osdctl -s "Reconfiguring,"} {Reconfigure}
    Same goes for turning off your keys (though I haven't found a way to provide feedback when turning the keys back on):
    Control Escape     		 :MacroCmd {Exec osdctl -s "Keys off,"} {keyMode KeysOff Control Escape}
    Other ideas include dynamic display of currently playing artist/album/etc. Most music players offer a command line interface (possbily through add-ons) to access this information:
    Mod4 p					:Exec osdctl -s "$(<command_to_get_music_info_string>)"
    or notification of long running processes:
    Mod4 p					:MacroCmd {osdctl -s "start"} {<start_long_running_process_command>} {osdctl -s "finished"}
    I'm sure there are many other possibilities, but its truly worth it for the volume adjustment alone.

    -toggle conky.

    I don't need conky most of the time, but now its available at a key press. And when I'm finished the same key will turn it off. Why waste resources when you don't need to?
    Mod4 c							:ToggleCmd {Exec conky} {pkill conky}
    -show (Mod4 s ...) and edit (Mod4 e ...) Fluxbox config files. Quick access to your fluxbox files in read-only or edit modes. NOTE: The show lines require 'gmessage' which can be found in the repositories. Alternatively, I believe you should have xmessage installed by default. To use xmessage change 'gmessage' to 'xmessage' and '--file' to '-file'
    Mod4 s Mod4 k   		 :Exec gmessage --file ~/.fluxbox/keys -buttons "Close" -font "monospace 8" -geometry 500x800 -default "Close" -center
    Mod4 s Mod4 a   		 :Exec gmessage --file ~/.fluxbox/apps -buttons "Close" -font "monospace 8" -geometry 500x800 -default "Close" -center
    Mod4 s Mod4 m   		 :Exec gmessage --file ~/.fluxbox/menu -buttons "Close" -font "monospace 8" -geometry 800x800 -default "Close" -center
    Mod4 s Mod4 i   		 :Exec gmessage --file ~/.fluxbox/init -buttons "Close" -font "monospace 8" -geometry 500x800 -default "Close" -center
    Mod4 s Mod4 o   		 :Exec gmessage --file ~/.fluxbox/overlay -buttons "Close" -font "monospace 8" -geometry 800x800 -default "Close" -center
    #These require a $CONSOLE path variable to exist.  Alternatively, replace '$CONSOLE nano' below with the name of your favorite text editor.
    #e.g. Mod4 e Mod4 k  		  :Exec gedit ~/.fluxbox/keys
    Mod4 e Mod4 k   		 :Exec $CONSOLE nano ~/.fluxbox/keys
    Mod4 e Mod4 a   		 :Exec $CONSOLE nano ~/.fluxbox/apps
    Mod4 e Mod4 m   		 :Exec $CONSOLE nano ~/.fluxbox/menu
    Mod4 e Mod4 i   		 :Exec $CONSOLE nano ~/.fluxbox/init
    Mod4 e Mod4 o   		 :Exec $CONSOLE nano ~/.fluxbox/overlay
    -launch fbrun (you can also prepopulate some or all of the text fbrun is to execute) This allows quick access to a command prompt/launcher
    Mod4 r   :Exec fbrun
    Mod4 r   :Exec fbrun -text "Pre loaded text string goes here"
    -Custom menus (available since v1.0rc3). This has real possibilities, especially for people like me who tend to forget less common key bindings. The custom menu allows you to construct a new menu from scratch and attach it to a key binding. It combines the power of key binding access with a focused GUI interface. For example, I have a session menu (lock, reboot, shutdown, switch user, etc.), file manager menu (open my GUI file manager (Thunar) at various locations), and a music player menu (stop, play, rewind, forward, choose playlists, etc..). See screenshots below for what these menus look like.

    #The 'Menu' key is located to the left of my right Ctrl key on my keyboard and has a picture of a drop down menu on it.
    Shift Menu					  :CustomMenu ~/.fluxbox/customMenus/Session
    Control Menu		 		  :CustomMenu ~/.fluxbox/customMenus/Thunar
    None Menu			 		  :CustomMenu ~/.fluxbox/customMenus/Amarok
    Here's the menu code for the Amarok menu in the screenshot below
    [begin] (Amarok) 
    		 [exec] (Show OSD) {/usr/bin/dcop amarok player showOSD} <>
    		 [exec] (Previous) {/usr/bin/dcop amarok player prev} </usr/share/icons/gnome/16x16/actions/player_rew.png>
    		 [exec] (Stop) {/usr/bin/dcop amarok player stop} </usr/share/icons/gnome/16x16/actions/player_stop.png>
    		 [exec] (Pause) {/usr/bin/dcop amarok player pause} </usr/share/icons/gnome/16x16/actions/player_pause.png>
    		 [exec] (Play) {/usr/bin/dcop amarok player play} </usr/share/icons/gnome/16x16/actions/player_play.png>
    		 [exec] (Next) {/usr/bin/dcop amarok player next} </usr/share/icons/gnome/16x16/actions/player_fwd.png>
       		 [submenu] (PlayLists) {}
    		 		 [exec] (Newest Tracks) {/usr/bin/dcop amarok playlistbrowser loadPlaylist "Newest Tracks"} <>
    		 		 [exec] (Never Played) {/usr/bin/dcop amarok playlistbrowser loadPlaylist "Never Played"} <>
    		 		 [exec] (Most Played) {/usr/bin/dcop amarok playlistbrowser loadPlaylist "Most Played"} <>
    		 		 [exec] (Electronica) {/usr/bin/dcop amarok playlistbrowser loadPlaylist "Electronica"} <>
    		 		 [exec] (Chillout) {/usr/bin/dcop amarok playlistbrowser loadPlaylist "Chillout"} <>
    		 		 [exec] (Favorite Tracks) {/usr/bin/dcop amarok playlistbrowser loadPlaylist "Favorite Tracks"} <>
    		 		 [exec] (All Collection) {/usr/bin/dcop amarok playlistbrowser loadPlaylist "All Collection"} <>
    		 		 [exec] (50 Random Tracks) {/usr/bin/dcop amarok playlistbrowser loadPlaylist "50 Random Tracks"} <>
    		 [exec] (Quit) {/usr/bin/dcop amarok MainApplication-Interface quit} </usr/share/icons/gnome/16x16/actions/gtk-close.png>

    -Toggle between ShowDesktop and restore view
    Mod4 m :ToggleCmd {ShowDesktop} {DeIconify all originquiet}
    -Move and Resize Active Window to a set position and size. Setup a bunch of these to quickly arrange windows to any size/location you want
    Mod1 u :MacroCmd {Moveto 10 5} {ResizeTo 1260 590}
    -Take to workspace. Take the active window and yourself to specified workspace. This is great if you like using multiple workspaces (which you should!). Often, one workspace gets quite cluttered. Simple press the right key combo and you and your window are instantly transported to a nice clean workspace
    Mod4 F3 	  :TakeToWorkspace 3

    -Dynamically modify the alpha (aka Transparency) of the window decor, or turn the decor on and off completely
    Mod4 Mod1 bracketright 	:SetAlpha +5 +5
    Mod4 Mod1 bracketleft  	:SetAlpha -5 -5
    Mod4 Mod1 0	 			:ToggleDecor

    -KeyMode - Turn on and off sets of keys. These help simplify the need to store lots of key bindings using the same set of keys. Consider resizing and moving. Its useful to use the arrow keys to do this, but you will quickly burn through modifiers attempting to do this. Consider KeyModes instead. For the keyset below, press Mod4 w Mod4 r (w for window, r for resize). then use the arrows to resize your window. When finished press Escape to remove these temporary keybinding. Thus the same arrow/shift arrow keys can be used for both resizing and moving windows, but with different keymode activators. See the wiki entry for more detail.

    ## ResizeMode (Window, Resize) - when Mod4 w Mod4 r is pressed, all keys except the arrow keys are disabled.  Press escape to exit this mode.
    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
    ## MoveMode (Window, Move) - when Mod4 w Mod4 m is pressed, all keys except the arrow keys are disabled.  Press escape to exit this mode.
    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
    -Toggle and SetResourceValue have nice possibilities of changing boolean values in the init file. However, a change to the resource values requires a reconfigure for them to take effect. Unfortunately, reconfiguring within a toggle command resets the toggle command, meaning you'll never make it to the 'second' toggle. This 'feature' may get fixed in an upcoming SVN/GIT release. Get around this by binding two different keys:
    #Hide/Show toolbar with 2 macro commands until Toggle/Reconfigure bug/feature is fixed
    Mod4 comma		 		 :MacroCmd {SetResourceValue session.screen0.toolbar.visible false} {Reconfigure}
    Mod4 period		 		 :MacroCmd {SetResourceValue session.screen0.toolbar.visible true} {Reconfigure}

    -Swap style and/or backgrounds with key
    Some days you might like your simple background and accompanying style, other days the flashy background and matching style. Assign keys to swap these for you:
    Mod4 shift 1			:Exec fbsetbg <path_to_image_including_imageName>
    Mod4 shift 2			:SetStyle <path_to_style_file_or_style_directory>
    #or combine both to change the entire look of your desktop at a key press (note: this won't work for you unless you have this background and style in those locations!)
    Mod4 shift 1        :MacroCmd {SetStyle /usr/local/share/fluxbox/styles/bora_black} {Exec fbsetbg ~/.fluxbox/backgrounds/stOrmgreen--0}
    -Use wmctrl to manage applications. This little program will allow you to assign a key binding to an application such that if you press the key binding and the application is already running, then you will be taken to the instance already running, otherwise it will launch a new application. Great for a quick way to jump to an already open instance of an application. Find details here:

    -Turn off key-bindings temporarily (e.g. if one of your keys conflicts with an application you are using). Pressing Control-Escape will turn off all key-bindings until Control-Escape is pressed again. This is useful if you use Xnest (which allows you to have multiple running X-sessions each in their own window) where you don't want Fluxbox intercepting key strokes meant for the other sessions. Or perhaps an application uses the same keys as the ones you've bound. Either way, its quick and easy to turn them off. NOTE: The second line preserves the right-click root menu so you're not trapped without a way to get to your Fluxbox root menu.
    Control Escape              :keyMode Xnest Control Escape
    Xnext: Control Mod1 Mod4 Mouse3		:RootMenu
    -Screen shots - Print the entire screen (None Print) or just the active window (Mod4 Print). The ~/screenshots directory must exist or this will fail. These also require imageMagick package to be installed (which contains the import utility). To install this use:
    sudo aptitude install imagemagick
    Alternatively, install scrot and swap the correct screenshot commands below.
    None Print     :Exec import -window root ~/screenshots/desktop_screenshot$(date +%F,%T).png
    Mod4 Print     :Exec import -frame -window $(xprop _NET_ACTIVE_WINDOW -root | awk '{print $5}') ~/screenshots/active_window_screenshot$(date +%F,%T).png
    -Quick calendar for this month, 3 months (previous month, this month and next month), or a full year
    Mod4 KP_1 :Exec zenity --calendar --text=""
    Mod4 KP_2 :Exec (date +'Today: %A %b %d';echo;cal -3)| gmessage --file - -buttons "GTK_STOCK_CLOSE" -font "monospace 8" -geometry 500x190 --borderless -default "GTK_STOCK_CLOSE" -center
    Mod4 KP_3 :Exec (date +'Today: %A %b %d';echo;cal -y)| gmessage --file - -buttons "GTK_STOCK_CLOSE" -font "monospace 8" -geometry 500x525 --borderless -default "GTK_STOCK_CLOSE" -center
    -Get root menu anywhere with the mouse. If you like to use the mouse right-click to pull up the root menu, add this to your keys file. Now you can pull up a root menu anywhere without having to hunt for some free desktop space.
    Mod4 Mouse3			:RootMenu
    -Turn on power-save mode on the monitor This will blank your monitor and put it into power save mode. I also use this on my laptop to activate the turn monitor off when the lid closes. Run 'xev' to find out what key binding to use for laptop lid closure.
    #Keyboard controlled turn monitor off
    None Pause		 		 :Exec xset dpms force off
    #214 is the keycode associated with my laptop lid closure/opening
    None 214	                           :Exec xset dpms force off
    One final keyboard/mouse shortcut I'll point out has nothing to do with the keys file. I love fluxbox, but the styles I use have small resize handles and thin window titlebars. This makes resizing and moving windows a pain, especially with my focus on mouse over policy (since if you overshoot the resize-handle you raise the window beneath it). Try this instead:

    Press Alt and Left mouse click anywhere in a window, then drag the mouse. This will now allow you to move the window
    Press Alt and Right mouse click anywhere in a window, then drag the mouse. This will now allow you to resize the window (anchored at the top left corner).

    5) Common Mistakes/Gotcha's/Troubleshooting

    If you plan on making changes to your keys file, I'd recommend turning on logging in fluxbox. This will output (by default) a log file to ~/.fluxbox/log which will tell you if fluxbox failed to bind any of the keys in your file. Very handy if your keys file is large like mine and you accidentally bind an action to an identical key sequence. To turn on logging, look at the last few lines of ~/.fluxbox/startup. There should already be a commented out line which contains the correct command to turn on logging. Simply comment out the current non-logging line and uncomment out the logging line. Be aware, however, that if you've compiled fluxbox from source, the path to fluxbox may not be correct in the logging line. So make sure that the path of your new fluxbox command matches the same path as the one you've just commented out.

    #Executable for logging:  exec <path_to_fluxbox_executable> -log "<path_to_log_file>"
    #This is MY path to fluxbox.  Yours will be different if you haven't compiled it from source.
    exec /usr/local/bin/fluxbox -log "/home/cknight/.fluxbox/log"
    If you get stuck and truly muck up your keys file, you may find yourself in a situation where you can't access your root menu to reconfigure any changes you make. Or maybe you can't even launch a terminal to make the changes! To fix this, press Ctl-Alt F1 to access a virtual terminal, log in, and type:
    nano ~/.fluxbox/keys
    at the command prompt if you need to edit your keys file, or perhaps restore the old keys file from a backup copy. In either case, after making corrections or restoring backups, type
    kill -s USR2 `xprop -root _BLACKBOX_PID | awk '{print $3}'`
    	OR (if you have session.screen<N>.allowRemoteActions set to true in your init file)
    fluxbox-remote "Reconfigure"
    to force fluxbox to reconfigure. Ctl-Alt F7 should take you back to the fluxbox GUI and your right-click root menu should now hopefully be back and working (assuming you fixed the problem!). This command isn't available on all fluxbox versions.

    Here are a list of things which might go wrong with your keys. Heh, I've made most of these

    1. Try to avoid these syntax pitfalls:
      • Code:
        Mod4 f 	: Exec firefox
        Make sure there are no spaces between the ':' and the start of the action otherwise you're biding won't work
      • Code:
        Mod4 f:Exec firefox
        Make sure there *is* at least one space between the shortcut key ('f' in this instance) and the ':'
      • Code:
        Mod4 f 	:Exec "firefox"
        Though double quotes (") appear to work on some commands, but they won't on all. Leave quotes out of the command, they aren't necessary.

    2. Careful to not use the same key combo. In this scenario, fluxbox will discard the second key mapping as Mod4 f is already bound.
      Mod4 f  :Exec firefox
      Mod4 f Mod4 1 :Exec Thunar
    3. Avoid using Mousetop1, Mousetop2, etc. in your keys file. These are put there by fluxkeys (see the warning about this program above) and cause fluxbox problems with your mouse clicks. To fix this, change these to Mouse1, Mouse2, etc.
    4. Key literals from 'xev' are case sensitive. So, 'Backspace' is not the same as 'BackSpace', 'backspace', etc.
    5. Applications to launch are case sensitive. 'Firefox' won't work because the actual command is 'firefox'. Try testing any command on the command line to ensure it works.
    6. Some key combinations just don't work. I setup one combination where the modifiers worked with other keys, the key worked with other modifiers and the command to execute worked with other combinations. Moral of the story, if it just won't work, try a different key combination/binding
    7. Perhaps avoid Control Backspace or Mod1 Backspace as a binding, since you might, like me accidentally press Control Mod1 Backspace instead which restarts X. Oops!
    8. If you have emacs-style multiple key bindings specified (e.g. Mod4 f Mod4 a :Exec firefox) in your keys file and at some point you find that none of your key bindings work, try pressing escape. You may have accidentally triggered Mod4 f and Fluxbox is waiting for a valid completion of the sequence. Escape should cancel multi-bound sequences.
    9. It appears that applications will override your keys file, so be sure to choose safe key combinations. E.g. Amarok binds 'Mod4 m' to mute, overriding my key-binding to launch my mail program. To fix this I just turned off all the key bindings in Amarok, since I've rebound them in fluxbox anyway.
    10. Reconfiguring will reset all of your toggles back to the first state, so if a toggle doesn't do what you think it should, keep this in mind. In particular, avoid placing the reconfigure command within a toggle, as this will continuously reset the toggle.

    6) Further info/Credits
    fluxbox wiki - some good how-to articles and more documentation on the keys file
    fluxbox man page - 'man fluxbox' - one of the best documented man pages I've seen, this covers all of the commands available to the keys file in reasonable detail
    fluxbox web documentation
    Multimedia keys tutorial
    IRC channel on freenode: #fluxbox
    How to install fluxbox from source

    Keys files from some of the folk closely related with Fluxbox
    Tenr's key file
    Mark Tiefenbruck's keys file
    Mathias Gumz (aka akira) keys file

    Menu and other fluxbox customizations

    Final note on the attached keys file. This forum doesn't allow upload of files without extension. So, the easiest thing to do was upload it as a tar file. To use the keys file attached below (as a .tar file), please perform the following steps:
    cd ~/.fluxbox
    cp keys keys.original
    cp <location_of_tar_file>/keys.tar ~/.fluxbox
    tar -xvvf keys.tar
    This will create a new keys file, overwriting your old one. Don't forget to reconfigure or your keys file won't be updated.

    Phew. You made it. Thanks for reading! Please contribute any of your own key bindings below. I'd love to see what things you've come up with. I'm quite positive that there's a lot of untapped potential from keys out there, so show us what you've got

    File list:
    1) Screenshot of custom menus
    2) Screenshot of osd (on screen display) of volume change
    3) keys.tar - contains my (large!) 'keys' file. See instructions above.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by cknight; December 18th, 2007 at 02:39 PM. Reason: Minor improvements/added developers comments

  2. #2
    Join Date
    Mar 2006

    Re: HOWTO: The power of Fluxbox keys

    Just wanted to say thanks for what was obviously a lot of work. I didn't want to go as deep down the rabbit hole as you, but the defaults stunk so bad I had to do something. I read your post before I read the official wiki, which seemed make the wiki easier to thanks again!

    Here's my key file after a few hours of reading and playing:
    OnDesktop Mouse1        :HideMenus
    OnDesktop Mouse2        :WorkspaceMenu
    OnDesktop Mouse3        :RootMenu
    Mod1 Tab                :NextWindow
    Mod1 Shift Tab          :PrevWindow
    Mod1 Control Right      :NextWorkspace
    Mod1 Control Left       :PrevWorkspace
    Control q               :Close
    Control Alt d           :ToggleCmd {ShowDesktop} {DeIconify all originquiet}
    Mod4 e                  :RootMenu
    Mod4 l                  :ExecCommand "xlock -mode matrix"
    Mod4 r                  :ExecCommand grun
    None XF86AudioLowerVolume       :Exec amixer sset PCM,0 5%-
    None XF86AudioRaiseVolume       :Exec amixer sset PCM,0 5%+
    None XF86AudioMute              :Exec amixer sset PCM,0 toggle

  3. #3
    Join Date
    Feb 2007

    Re: HOWTO: The power of Fluxbox keys

    Quote Originally Posted by n8bounds View Post
    Just wanted to say thanks for what was obviously a lot of work. I didn't want to go as deep down the rabbit hole as you, but the defaults stunk so bad I had to do something. I read your post before I read the official wiki, which seemed make the wiki easier to thanks again!
    Glad it helped! The deep rabit hole, as it were, is mostly to show the breadth and depth of possibilities. I hope others, like you, pick and choose what works best for them.

  4. #4
    Join Date
    Jun 2007
    Ubuntu 9.04 Jaunty Jackalope

    Re: HOWTO: The power of Fluxbox keys

    How do you access the osdshconfig utility?
    Ubuntu User # 17490
    Currently: Fisheye 2, Diana F+, Viv UWS

  5. #5
    Join Date
    Feb 2007

    Re: HOWTO: The power of Fluxbox keys

    Quote Originally Posted by rjmdomingo2003 View Post
    How do you access the osdshconfig utility?
    You should just be able to type this on the command line:
    If not give me a shout and I can post my theme

  6. #6
    Join Date
    Jul 2006

    Re: HOWTO: The power of Fluxbox keys

    Wow. Thank you very much. This is a great guide -- plenty of good ideas!

  7. #7
    Join Date
    Feb 2007

    Re: HOWTO: The power of Fluxbox keys

    Quote Originally Posted by urukrama View Post
    Wow. Thank you very much. This is a great guide -- plenty of good ideas!
    Thanks! Glad it helped. As an openbox user, I'd be curious to know how much of this is portable to openbox and how the key bindings compare.

  8. #8
    Join Date
    Jun 2007
    Ubuntu 9.04 Jaunty Jackalope

    Re: HOWTO: The power of Fluxbox keys

    Quote Originally Posted by cknight View Post
    You should just be able to type this on the command line:
    If not give me a shout and I can post my theme
    Yay! Got my osdtheme to work! Thanks cknight
    I've attached a screenie of the osdtheme.. Master volume for now..
    Attached Images Attached Images
    Ubuntu User # 17490
    Currently: Fisheye 2, Diana F+, Viv UWS

  9. #9
    Join Date
    Apr 2006
    Kubuntu Development Release

    Re: HOWTO: The power of Fluxbox keys

    Quote Originally Posted by cknight View Post
    Thank you for this detailed guide. I posted a link on the Fluxbuntu forums.
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

  10. #10
    Join Date
    Feb 2007

    Re: HOWTO: The power of Fluxbox keys

    Quote Originally Posted by rjmdomingo2003 View Post
    Yay! Got my osdtheme to work! Thanks cknight
    I've attached a screenie of the osdtheme.. Master volume for now..
    Looks great! I like how you've matched the color to your style...

Page 1 of 5 123 ... LastLast


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts