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.

  • 3
    In that case, why does it need to be for a single application? Why not change it with setxkbmap or whatever shortcut you have assigned to the switch, play your game, and then switch back when done? – terdon Nov 26 '16 at 12:08
  • kbdd should work under most WM, but there may be a better way with Awesome. Under Sawfish, I ended up running xmodmap on a window switch. – Gilles 'SO- stop being evil' Nov 26 '16 at 23:11

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.