Title: Tiling, for Great Justice! Created: 2016-10-13 Life's been somewhat aggravating lately. I find myself being interrupted because someone, somewhere, thinks my attention is better spent on something they think is important. Most of this is virtual, which led me to ask myself, "What can I do to improve the signal vs. noise ratio when I'm at the computer?" My immediate first thought was tiling window managers. I've tried a good number of tiling window managers: dwm, wmii, ratpoison, scrotwm, awesomewm, and i3. awesomewm was the only one I really stuck with, mostly because it did everything I wanted it to, out of the box. That turned into a hassle as they advanced to awesomewm 3, and then again at some point later on. By the time I came back to using awesomewm again, the API would change and I'd have to rewrite or refactor my config altogether. That's a sure sign that the software is a toy rather than a tool, imo. There's nothing wrong with that; awesomewm lives up to its name most of the time. However, that history colored my outlook. I decided it was time to try out i3 again. The reason I didn't stick with i3 back in the late 2000s is I couldn't find a way to move windows from one container to another; I (mistakenly) thought trees were self-contained and couldn't be modified, moving windows around and whatnot. When I came back to i3 this morning, I was pleasantly surprised that it _did_, in fact, have that ability. So I fired up i3, let it set my default config, then hacked at it until it resembled something usable to me. The last piece of the puzzle is one that, for me, is mandatory: if I decide I'd rather use Fluxbox, I need to be able to switch to it with all the current windows still around. Fluxbox already plays well with other window managers, and awesomewm did as well. Unfortunately, i3 doesn't play that game. That's okay, though, because X11 has interesting behavior inside ~/.xinitrc. Generally, the last line of that file should be `exec foo`, where foo is a window manager. `exec` gives control to the process it starts and tells xinit not to do anything further in the script. That's great if you're happy with your window manager and have no need to switch. Since i3 lacks the ability to hand over control, however, I had to use bash to my advantage. What I did was fairly simple, so I'll just let the snippet speak for itself: (put this at the bottom of .xinitrc and comment out any "exec" calls before it) ---CODE START--- # This opens up window manager switching without extra dependencies while true; do if [[ -f "$HOME"/.wm ]]; then WM=$(cat "$HOME"/.wm) fi if [[ -n $WM && -x $(which "$WM") ]]; then $WM # Check the contents of the file before acting _nextwm=$(cat "$HOME"/.wm) if [[ "$WM" == "$_nextwm" ]]; then # Let X exit normally if ~/.wm matches the WM that was last ran. break fi else # Let the user know they need a valid WM command echo "xinitrc: window manager command in ~/.wm not set or not executable, exiting." break fi done ---CODE END--- It's not perfect (likely insecure unless you chmod 600 ~/.wm), but it correctly switches WMs when needed, and exits when the running WM matches what's in the file. Tying this together was literally two lines; one in ~/.fluxbox/keys: Mod4 Ctrl t :MacroCmd {Exec echo 'i3' > ~/.wm} {Exec killall -9 conky} {Exit} ...and one in ~/.config/i3/config: bindsym $mod+Shift+x exec "echo 'fluxbox' > ~/.wm", exit The end-result is I can use keybindings to switch between window managers at will. So if I get the sudden urge to write some code, I can switch to i3, get a workspace set up for some work, hammer it out, and come back to Fluxbox to resume watching funny cat videos or something else inane. :) If you found this interesting or fun, leave a note on the guestbook!