====== Fluxbox ====== NB This is from a long time ago in a galaxy far away. January 2016 in fact. I changed to ''**i3wm**(1)'' and now use ''**sway**(1)''. It might still be useful, who knows? ==== A keyboard-heavy, para-tiling configuration ==== Everyone's desktop experience is different. KDE users like one thing. Gnome users like another - then there's Gnome Classic, Gnome Modern, LXDE and XFCE ... A common theme in all these is "Multiple Overlapping Windows managed by the User via the Mouse." They're all OK as far as they go, but something about them all has annoyed me over the years - the amount of time spent re-sizing and flipping between all the different windows and the waste of space around the edges of the nest of windows. Often I find myself trying to get the most out of my screen real-estate by lining up windows to each other and stretching them out to the screen edge - some WM's make this a bit easier by snapping the moved corner to an existing edge. But it's still a lot of work. Just try clicking and dragging 2 or 3 windows so they have a visually pleasing equal size, without wasteful gaps and fill the screen completely. For another thing, it's just too fiddly to drive the mouse into those tiny window-corner re-sizing tools and drag them around. So I thought I'd try tiling window managers - **awesome**(1), **xmonad**(1), **dwm**(1) ... there are many, and I've tried a few. None, so far, really do it for me for one reason or another. Perhaps it's because I don't want tiling absolutely everywhere. I like to have docks and gkrellm running on all desktops and some tiling managers don't do that sort of thing well. **STOP THE PRESS: I discovered i3 and it's fabulous** Or maybe I'm just too bedded in with **fluxbox**(1). Whatever, I have evolved (and present here) a bunch of scripts that use **wmctrl**(1) and should, therefore work with any WM, not just **fluxbox**(1). I also have a nice, consistent and easily memorised set of key assignments in a **fluxbox**(1) {{fluxbox:keys|keys}} file - but they could easily be ported to Gnome or KDE and I have done that too. Unfortunately, the Gnome and KDE formats for key assignments are not so easily ported around but if there's interest I will provide what I've done with them. The scripts plus the key bindings provide a para-tiling approach - tiling where I want it, non-tiling elsewhere with really snappy key assignments that save me from all that tedious mouse clicking and dragging stuff. Just imagine - a single key press to marshall all your windows into a consistent size and neatly tesselated across the screen. I should mention that mostly what I do is develop code of some sort or other. Vertical pixels are more valuable to me than horizontal pixels as they are the limiting factor on the number of lines of code that I can see on one screen. That's extra important on today's letterbox 16:9 displays - and there's just no way to turn a laptop screen into portrait mode! So I tend to push my docks, clock and gkrellm off to the RHS of the screen and have no top or bottom bar. My normal work setup with ''tile -3'' which is assigned to key ''S-C-M-3'': {{:tiled.png}} A more extreme example with ''tile -9'': {{:wot.png}} What I'll try and do here is give a breakdown of each feature of my **fluxbox**(1) usage. Maybe it'll be useful to someone. In all the keys assignments presented here: * ''C-d'' means Control-d * ''M-d'' means Meta-d. Meta is the Alt key so this is the same as Alt-d. This is referred to as Mod1 in **fluxbox**(1)'s keys file. * ''S-d'' means Shift-d * ''S-C-M-D'' means Shift-Control-Meta-d (!) * ''Mod4-d'' means 'd' while the 'flag' key is held down * mostly I adopt the convention that key assignments that the Window Manager (ie **fluxbox**(1)) will trap have ''C-M-'' or ''S-C-M'' modifiers - this avoids conflict with most Emacs and other common app key assignments * mostly, I have arranged Mod4 (the flag key modifier) to have the same effect as ''C-M-''. Thus, for example, ''Mod4-2'' resizes the window to half-screen size and is the same as ''C-M-2'' * the scripts should work sensibly with multiple monitors although only 2 have been tested. * pretty much all my scripts are run on all my machines, desktop and laptop, without alteration. Anything that's specific to work, or to a lappy gets coded around. That way, I can share my scripts freely on all my machines. =====Installing & Starting fluxbox===== [[http://fluxbox.org/|fluxbox]] was my favourite screen manager for many years - it's minimal and fast, it allows me to use the 'hot' keys that I like (eg Mod4-x runs my favourite xterm **konsole**(1) - in fact, I almost have no need to use the mouse (until the browser runs, anyway!). By the way, I'm not too into 'themes' so look elsewhere for pure eye-candy - this is automation stuff. Also, these scripts are specific to my machines and environment - some of them won't be much use unless you edit them to your own needs - please don't run anything marked * without editing it first. === Installing fluxbox (on fedora): === Fedora doesn't have a 'spin' for fluxbox so you need to start with something else. The default fedora install uses Gnome, but there are spins for KDE, XFCE and LXDE. I generally use the LXDE spin as it's pretty light and doesn't have all the Gnome/KDE junk that I'm unlikely to use. * Disable SELinux in /etc/selinux/config (not essential, but I prefer it that way) * install rpmfusion (actually needed for mythtv and others but very useful to have around): rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm === install the essentials: === yum install fluxbox feh wmctrl xmessage inotify-tools xvkdb xscreensaver zenity === other nice to haves: === yum install mrxvt gkrellm emacs nitrogen konsole # customise this to your own taste! === remove evils: === gnome-screensaver used to be fairly useful and it used to play nice with xscreensaver - nowadays (eg fedora-14) it's braindead and it runs no matter what you do. Something to do with d-bus. Whatever, it's just a lot easier to get rid of it: rpm -e gnome-screensaver === login manager setup - gdm/kdm/lxdm etc === Getting gdm, lxdm, kdm, etc to offer **fluxbox**(1) as well as gnome/kde etc is probably more fully documented elsewhere, but this is what I use: * {{startup:.xsession|.xsession}} * : drop this in your home directory. * {{startup:xsession.desktop|/usr/share/xsessions/xsession.desktop}} : .xsession _should_ be called by gdm and kdm. However, on fedora, I needed to install xorg-x11-xinit-session. I've a somewhat longer treatment of this here: [[starting_x]] === Using startx === Some people prefer to live without a login manager; me too, sometimes. In this case a couple of extra things need to be supplied - **startx**(1) will call your {{startup:.xinitrc|.xinitrc}} * file. In turn, this calls your {{startup:.xsession|.xsession}} file as above. === Starting up fluxbox === I have a single set of scripts for all my machines and environments, home and work: * {{fluxbox:startup|.fluxbox/startup}} * * {{fluxbox:keys|.fluxbox/keys}} * * {{fluxbox:menuconfig|.fluxbox/menuconfig}} * * {{fluxbox:usermenu|.fluxbox/usermenu}} === Scripts to generate menus etc === (some of these rely on {{scripts:argp.sh|argp.sh}} from this site - see [[scripts]]): * {{scripts:update-user-menu|bin/update-user-menu}} * * {{scripts:update-gnome-menu|bin/update-gnome-menu}} * * {{scripts:update-march-menu|bin/update-march-menu}} * : modified from the original 'march menus' (BTW - my version is _much_ faster and results in fewer things chucked in the too-hard 'uncategorised' basket!!) * {{scripts:gnome-menus-ls.py|bin/gnome-menus-ls.py}} * : this is from gnome-menus-2.30.4-1.fc14.src.rpm * {{scripts:watch-files|bin/watch-files}} : this keeps an eye on the filesystem and updates menus automatically when things change. * {{startup:watched-files|.config/watched-files}} * : configuration file for watch-files and update-dvd-menu === Other useful scripts === * {{scripts:next-desktop.pl|next-desktop.pl}} : handles navigation between workspaces: * {{scripts:find-app|find-app}}: looks for running apps and switches workspace to them or starts them up * {{scripts:browser|browser}} * : invokes the browser - it looks for something already running (firefox, chrome, konqueror etc), otherwise it looks at $BROWSER, then your gnome preference. If all else fails, it just picks a browser to run. * {{scripts:myterm|myterm}} * : runs a terminal - it looks for the various common terms and tries to run one in a fairly consistent way. * {{scripts:half-screen|half-screen}} : sets a window to half the physical screen (or quarter, third, sixth etc with -3, -4, -6 etc) * {{scripts:tile|tile}} : rearranges all windows to tile on the current desktop. Optionally re-sizes them (with half-screen) to half, quarter, third of a screen etc. * {{scripts:move-window|move-window}} : Move the window to Left, Right, Top, Bottom, TopLeft, TopRight etc === Laptop peculiarities === These are not specific to **fluxbox**(1) so I've put them [[laptop_hacks|here]] NOTE: * = edit these before using ===== Work Spaces ===== In workspace 1 I generally place a number of terminals (I like konsole) and emacs windows all tiled without window decorations. On the other workspaces I have other apps running - eg a browser, maybe **rapidsvn**(1) for svn GUI operations - although mostly I use CLI **svn**(1). Maybe a **vncviewer**(1) back to my home server to keep an eye on downloads and TV recording. A VirtualBox running Windows for corporate apps. You get the idea. For navigating between these I use a consistent set of ''C-M-'' commands. Thus: * ''C-M-up/down/left/right'' jumps me to the workspace in that direction (**fluxbox**(1) has a 2-dimensional set of workspaces). * ''S-C-M-up/down/left/right'' does the same but also sends the current window to that workspace. * ''C-M-KeyPad1/2/3'' ../etc jumps me to that workspace. * ''S-C-M-KeyPad1/2/3'' ../etc does the same and sends the current window to that workspace. * ''Mod4-Mouse-1/2/3'' also jumps to that workspace. This is surprisingly useful for rapid jumping around, particularly as VirtualBox leaves those combinations alone even in fullscreen mode. * ''Mod4-F1/2/3'' jumps to workspace 1/2/3 ../etc As usual, ''Mod4-'' can be used instead of ''C-M-'' in the above key assignments. ===== Moving Windows Around===== Moving windows around is a royal pain if you need to faf about with getting the mouse cursor on the title bar and then drag it around. To make it a little easier I map ''M-Mouse1-drag'' with the cursor anywhere on the window to start moving the window. That's 'press Alt, then left button and drag the window around'. This gives me a much bigger target. To pop a window to be above all others (ie to be the front-most window) I have ''M-Mouse1'' on the window. To push a window to the bottom (ie all others are in front of it) I have ''M-Mouse2'' (middle button) on the window. Surprisingly, this is actually more use than ''M-Mouse1'' as it allows you to cycle through a stack of windows. On some of my keyboards, the ''Home, End, PgUp'' and ''PdDn'' keys form a square. So I map them (when combined with ''C-M-'' keys) to let me quickly move windows about the screen: * ''C-M-Home'' Sends window to the left of screen * ''C-M-End'' Sends window to the right of screen * ''C-M-PgUp'' Sends window to the top of screen * ''C-M-PgDn'' Sends window to the bottom of screen * ''C-M-c'' Sends window to the centre of the screen * ''C-M-['' Moves window left by its width * ''C-M-]'' Moves window right by its width * ''S-C-M-['' move window up by its height * ''S-C-M-]'' move window down by its height If I want to send a window to a corner, I use these: * ''S-C-M-Home'' Sends window to the top left corner of screen * ''S-C-M-End'' Sends window to the bottom left corner of screen * ''S-C-M-PgUp'' Sends window to the top right corner of screen * ''S-C-M-PgDn'' Sends window to the bottom right corner of screen These look fearsome but it's amazing how your finger memory handles it after a couple of goes. There's always the window menu (''S-Menu'') if you can't recall the key chords. For fine tuning, I use these: * ''S-C-Mod4-Left/Right/Up/Down'' moves window by 1 pixel * ''S-C-M-Mod4-Left/Right/Up/Down'' moves window by 10 pixels Also, there is a 'move window mode' where the direction keys ''Up'', ''Down'', ''Right'' and ''Left'' move the window by 1-pixel and 10-pixels if shifted: * ''S-C-M-y m'' start window-moving mode * ''Esc'' stop window-moving mode As usual, ''Mod4-'' can be used instead of ''C-M-'' in the above key assignments. =====Resizing Windows===== Finding those darn resize corners can be a royal pain. The **fluxbox**(1) default of ''M-Mouse3'' "anywhere in a window" resizes from the nearest edge and is quite useful. That said, I rarely use it and rely more on the tiling commands: * ''C-M-2'': resizes to half a screen * ''C-M-3'': resizes to third of a screen * ''C-M-4'': resizes to a quarter screen * ''C-M-m'': maximise the window * ''S-C-M-m'': toggle fullscreen for the current window * ''C-M-h'': maximise the window vertically ('h' for 'high') This is enough for me but I also have window menu items (''S-Menu'') for half, third, quarter, sixth and ninth of a screen. I find that 3 windows of 1/3 screen are just about right for coding on typical 1980x1280 screen - two emacs windows and one terminal. For fine tuning, I use these: * ''S-C-Mod4-KP_Left/KP_Right/KP-Up/KP_Down'' resize window by 1 pixel * ''S-C-M-Mod4-KP_Left/KP_Right/KP-Up/KP_Down'' resize window by 10 pixels Also, there is a 'resize window mode' where the direction keys ''Up'', ''Down'', ''Right'' and ''Left'' keys resize the window by 1-pixel and 10-pixels if shifted: * ''S-C-M-y r'' start window-resizing mode * ''Esc'' stop window-resizing mode As usual, ''Mod4-'' can be used instead of ''C-M-'' in the above key assignments. =====Tiling===== Most of the tiling functionality is implemented in the {{scripts:tile|tile}} script. Then, I have this in the ''.fluxbox/keys'' file: * ''C-M-o'': tile all windows on this display Thus ''C-M-o'' arranges all windows on the current workspace and tiles them next to each other without resizing them. It works through all windows of the same class (eg all the terminals, then all the emacs windows etc) fitting them next to each other as far as possible. It start with the largest one, pushing it up into the top left corner, then works through the remainder. If it runs out of room, it starts again at the top left putting the next window above the previous one. All without touching the mouse. Of course, the most 'tiling-esque' effect happens when there is enough space for all the windows without overlap. Tiling doesn't really need window decorations, so: * ''C-M-k'': toggle window decorations (title bar etc) on and off on the current window. A very frequent use-case for me is to want all my windows to be the same size, tiled and without window decorations at all - after all, when you're tiled, you don't need the window decorations and you get an extra line for your editor or terminal in exchange for the title bar. Here are my key assignments for this: * ''S-C-M-2'': make all windows half screen and tile * ''S-C-M-3'': make all windows one third screen and tile * ''S-C-M-4'': make all windows quarter screen and tile Thus ''S-C-M-2'' operates on every window in the current workspace, removes the window decorations, re-sizes it to half screen and then tiles them next to each other. Again, no need for the mouse (of course, there's nothing stopping you from putting something in your menus if you can't remember the key-chord). As usual, ''Mod4-'' can be used instead of ''C-M-'' in the above key assignments. **fluxbox**(1) has an //ArrangeWindows// command - but it doesn't seem to do what I want. =====Menus===== Since I often remove window decorations and tile my working windows across the whole desktop, it can be hard to get to the menus. Here's a couple of keyboard shortcuts to pop up the menus: * ''C-M-d'': toggle desktop * ''Menu'': user menu (because that's the one I use the most!) * ''M-Menu'': workspaces menu * ''S-Menu'': window menu * ''C-M-Menu'': client menu * ''C-Menu / S-M-Menu / S-C-Menu'': Root menu As usual, ''Mod4-'' can be used instead of ''C-M-'' in the above key assignments. I have a bunch of scripting to build various menus - see the various menu files {{fluxbox:menuconfig}} {{fluxbox:menu}} {{fluxbox:usermenu}} {{fluxbox:user.menu}} {{fluxbox:windowmenu}} ../etc and the scripts {{scripts:update-user-menu}} ../etc But one thing that **fluxbox**(1) lacks is a way to get its menus to update automatically - eg when you install or delete new software, you'd want it to appear in the menus without having to remember to rebuild them. The {{scripts:watch-files|watch-files}} script here does just that. Check it out! =====Cut & Paste===== There are many Unix applications that cut and paste a little differently to what has become the de facto standard - ie ''C-x C-c C-v'' via the "clipboard". In X the subject is a little more complex with several additional sources for paste such as the PRIMARY selection ((whatever is selected on-screen is automatically copied and available to be pasted with the middle mouse button or (often) with Shift-Insert)). There are others, but rarely used so I won't go into them. If an application does not support the clipboard (eg **emacs**(1), most terminal emulators) then I can simulate it with the following keystrokes (which depend on **xclip**(1) and **xvkbd**(1)): * ''C-M-c'': copies the PRIMARY selection to the clipboard * ''C-M-v'': copies the clipboard into the keyboard stream ie as if it were pasted As usual, ''Mod4-'' can be used instead of ''C-M-'' in the above key assignments. =====Runnings apps===== Like me, your top 10 apps probably account for 99% of your use, so it's useful to have them directly at your fingertips rather than hunting through menus. You'll most likely want to customise these: * ''C-M-b'': browser * ''C-M-d'': hide all windows; reveal the desktop * ''C-M-e'': emacs * ''C-M-g'': calculator * ''C-M-i'': -- free -- * ''C-M-j'': -- free -- * ''C-M-l'': lock the desktop * ''C-M-n'': -- free -- * ''C-M-p'': -- free -- * ''C-M-q'': libreoffice spreadsheet * ''C-M-r'': fbrun - pops up a command line app launcher for when you don't want a terminal * ''C-M-s'': mail program ('s' for sylpheed, but I use others nowadays!) * ''C-M-t'': -- free -- * ''C-M-u'': -- free -- * ''C-M-w'': libreoffice word processor * ''C-M-x'': terminal * ''C-M-z'': truecrypt As usual, ''Mod4-'' can be used instead of ''C-M-'' in the above key assignments. Note that most key commands that invoke external apps are run through my script **xcheck**(1) which watches for errors and pops any up in a dialog window. It helps debugging. =====Auto-type===== How many times a day do you type your email address or password? The following keystrokes use **xvkbd**(1) to insert those strings into the keyboard buffer stream. Passwords need to be stored encrypted so I use **gpg**(1) for the storage and **gpg-agent**(1) to unlock the keystore (once a day!). All this is done with a couple of my scripts **lookup**(1) and **myautotype**(1). * ''C-M-1'': mobile phone number * ''C-M-5'': work password 1 (stored encrypted) * ''C-M-6'': work password 2 (stored encrypted) * ''C-M-7'': work password 3 (stored encrypted) * ''C-M-8'': email address (stored in plaintext) * ''C-M-0'': work email address (stored in plaintext) As usual, ''Mod4-'' can be used instead of ''C-M-'' in the above key assignments. =====Screen Dumping===== The script **myscreendump**(1) uses the X utilities **xwd**(1), ImageMagick and netpbm to enable various type of screen dumping: * ''Print'': dump a window to a png file * ''S-Print'': dump a window to a png file without the window decorations * ''C-Print'': dump a rectangluar area to a png file * ''C-M-Print'': dump the entire screen to a png file =====Multimedia===== These control the volume, backlight etc and use **amixer**(1). I don't use pulse, if I can help it!! * XF86AudioLowerVolume * XF86AudioRaiseVolume * XF86AudioMute * XF86AudioPlay * XF86AudioPrev * XF86AudioNext * XF86MonBrightnessUp * XF86MonBrightnessDown The ''play prev next'' buttons are specific to **mplayer**(1), my favourite media player. It needs a clause in ''~/.mplayer/config'' to create the fifo for this control. input=file=/home/bhepple/.mplayer/fifo If you don't use **mplayer**(1) you can reassign these keys as you like. =====Downloading===== For convenience, there are tarballs of my scripts here: * {{scripts.tgz}} * {{startup.tgz}} Installation: Put all the scripts somewhere on your $PATH - perhaps ''/usr/local/bin'' or ''~/bin''. As for the startup scripts: * ''startup usermenu keys menuconfig'' go in ''$HOME/.fluxbox'' (you may want to backup existing version of those files there). * ''.xinitrc .xsession'' go in ''$HOME'' * ''xsession.desktop'' which goes into ''/usr/share/xsessions''