How to assign two different keybindings for window switching (a.k.a Alt+Tab) in Linux

More interface tweaking

linux usability UI

I was assigned a Mac OS machine for a work project and started using it right away. I was immediately tripped up by the Mac keyboard layout. In general, I think the Mac keyboard layout is far more sensible than the standard PC layout, but to work comfortably without muscle memory tripping me up I needed to make some tweaks.

Muscle-memory requirements

Here are the constraints I had to satisfy:

1) The key right next to the spacebar (sometimes marked AltGr) needs to serve as a modifier key for Polish letters: ę ó ą ś ł ż ź ń.

2) I need window-switching to be operated by the same muscle movement in both my Mac and Linux environments.

The solution

Here's what I arrived at:

1) In Mac OS's keyboard settings, I swapped the Option and Command keys. This gives me my Polish glyph toggle under my right thumb, but forces me to alt+tab with the second neighbors of the spacebar on both sides, instead of the keys immediately flanking the spacebar.

2) To match the MacOS situation, I set my XFCE "window switcher shortcut" to Super+Tab. This is not very comfortable. On the Mac, I end up often using my Right Option + Tab for window switching, more often than Left Option + Tab. How do I match this setup on the Linux machine?

The answer turns out to be alttab. This is a standalone program which runs in the background and takes over your window manager's "alt-tab" functionality. It can readily replace whatever window switching your window manager provides for you. It's simple, fast, and does one thing well.

Alt-Tab under two different shortcuts

There is one problem, though: alttab can't use two distinct modifier keys to perform window switching. I'd like to use both Super_L+Tab and Control_L+Tab to switch windows, thereby matching the behavior on my mac.

The workaround is to launch two separate instances of alttab, each bound to its own key combination:

alttab -mk Control_R -s 0 -bg white -fg black &
alttab -mk Super_L -s 0 -bg white -fg black &

Now, my muscle memory for typing in Polish doesn't trip me up on my Mac, and I have a consistent Alt-Tab setup across both my systems. Not particularly beautiful, but at least consistent between platforms.