Linux – How to change the keyboard layout for a single application in Awesome WM

arch linuxawesomekeyboard shortcutskeyboard-layout

I've added keyboard shortcuts to set the global keyboard layout, but how do I set it for a single application? The reason I'd like to do this is that I'm used to QWERTY for gaming, and I'd rather not spend 10 minutes in every game to set up a custom layout. And I'd rather not have to switch layout when changing to other applications (which I do frequently), both for convenience and to avoid pressing the wrong shortcut.

Best Answer

To notice when a new app (your game) starts, use client.connect_signal("manage", function(c) ...). Then use client.name to see if it's your app ("kerbal-space-program", or whatever). If both tests pass, apply your keyboard layout.

For extra tidiness, test client.focus to enable/disable that keyboard layout on the fly.

https://awesomewm.org/doc/api/classes/client.html#

Related Question