Familiar Alt Tab

Installation
If you, like me, were bothered by the limited window-switching functionality that awesome has to offer by default, this module might be for you. It can be git clone'd directly from github: git clone https://github.com/jorenheit/awesome_alttab alttab Alternatively, the code can be pasted in ~/.config/awesome/alttab/init.lua. When the module is available, a keybinding can be added to your keybindings-table in rc.lua:

alttab = require("alttab")

awful.key({ "Mod1",          }, "Tab",                                                              function                                                                                          alttab.switch(1, "Alt_L", "Tab", "ISO_Left_Tab")                                                     end                                                                                          ), awful.key({ "Mod1", "Shift"  }, "Tab",                                                              function                                                                                          alttab.switch(-1, "Alt_L", "Tab", "ISO_Left_Tab")                                                    end                                                                                          ),

In the above snippet, we pass the keys that we want to function as "Alt" and "Tab". In this example, I'm using left Alt and Tab. The final parameter is the value that is captured by the keygrabber when Shift+Tab is pressed. When Alt-Tabbing, the arrow-keys can be used to navigate as well.

Update: it is now possible to break out of alt-tabbing using the Escape key. This will ignore the selected client and return to the previous state. Also, clients that don't have an icon associated with them, failed to preview in previous versions (e.g. urxvt). The updated version contains noicon.png to fix this issue. Be sure to copy this to your alttab-folder as well if you're copy-pasting instead of cloning.

Tested environments
Please add more when appropriate:
 * Awesome 3.5.5, built against Lua 5.1.5 (GCC 4.9.0)

Features
The image shows what the functionality might look like once installed, when only the preview-box is enabled. When cycling through your clients, using either alt-(shift)-tab or the arrow keys (while still holding alt), the selected client is illuminated and slightly magnified. After selecting a client, the focus history is updated accordingly, so that you can easily switch back and forth between your two most recent clients. Because this is a common practical use-case of Alt-Tab, a delay is built in to prevent the graphical interface to pop up when releasing Alt within some timeframe. For me, 100ms worked well, so this is the default.

A second mode of operation can be enabled (in place of, or replacing the previews) that applies an opacity effect to the clients themselves. In this mode, all but one client (the currently active one) are rendered somewhat see-through, making the non-opaque window stand out. Like with the preview-box, it's possible to set a delay on this effect to prevent it from being activated when using alt-tab to quickly switch back and forth between two clients.

Customization
preview_box = true, preview_box_bg = "#ddddddaa", preview_box_border = "#22222200", preview_box_fps = 30, preview_box_delay = 150,
 * The alttab.settings table contains the following fields, that may be altered to change the Alt-Tab behavior (default values are shown):

The above settings all apply to the preview-box, and are pretty self-explanatory. When preview_box is set to false, there won't be any previews at all, but of course the Alt-Tab functionality is still preserved. In addition to the above, the following settings are available:

client_opacity = false, client_opacity_value = 0.5, client_opacity_delay = 150,

The opacity-effect is disabled by default, but can be enabled by setting the client_opacity field to true. The alpha-value and delay-time (in milliseconds) can be tweaked to suit your needs/taste.

''Note that you need the `unagi' package to be installed and running on your system (on Debian: apt-get install unagi</tt>). You can run it by spawning it from rc.lua, or any other init-script.''

local a = 0.8 local overlay = 0.6 local fontSize = smallFont if c == altTabTable[altTabIndex] then a = 0.9 overlay = 0 fontSize = bigFont end The `a</tt>' value is the scale-factor by which the images are scaled with respect to the box they're drawn in. By default, this is 80%. Selected clients are scaled by 90%, such that it appears as if they're magnified when selected. The `overlay</tt>' value is actually the alpha-channel value of a black rectangle that's drawn on top of the images. By setting this to 0 for selected clients, it seems as if they get illuminated. local previewDelay = 0.1 -- 100ms local previewDelayTimer = timer({timeout = previewDelay})
 * You might want to edit the illumination/magnification effects when selecting clients, but this required editing the code itself (init.lua). Look for the following lines (in the draw</tt> function):
 * The preview-delay can be altered if 100ms isn't working for you. Just alter the timeout value of the previewDelayTimer</tt>:

Of course, feel free to mess around with it as much as you like, or even fork!