The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
2

Different keyboard layot for every window

asked Apr 18 '15

KirillTim gravatar image

Hello!
I'm new in i3 and I really love it more than other WMs. But I have an issue, which can be easy solved in other "gui" WMs: I want my change keyboard layout(from ru to us) keys switch layout only in active window, but not all X.
For example: I have terminal and chat. I type english in terminal, than switch to chat and have russian layout there(saved from previous typing) I've tried to google this issue, but failed. To be honest, i don't know which keywords should I use?

Comments

This is probably doable, but might require quite a bit of work. You could write a script that keeps an assignment of layouts to windows, listens to [i3events](https://i3wm.org/docs/ipc.html#_events), and whenever a different windows receives focus, it changes the layout the the appropriate one.

i3convert gravatar imagei3convert (Apr 20 '15)edit

1 answer

Sort by » oldest newest most voted
2

answered Apr 24 '15

gurkensalat gravatar image

updated Apr 26 '15

As i3convert commented already, you could try this approach; depending on your chat program you need to adjust the class name. This uses the i3subscribe script which I made available some weeks ago:

#!/bin/bash
i3subscribe window | grep window:focus | \
while read -r line; do
    id="$(xprop -root _NET_ACTIVE_WINDOW | awk '{print $5}')"
    case "$(xprop -id "$id" WM_CLASS | cut -d\" -f4)" in
        Firefox)        kb=de ;;
        ChatProgram)    kb=ru ;;
        *)              kb=us ;;
    esac
    setxkbmap "$kb"
done

Save, make the script executable and put it into the startup-applications.

Comments

Invalid link to i3subscribe script. I even can't google it. Could you, please post that script here for me.

KirillTim gravatar imageKirillTim (Apr 24 '15)edit
1

My post seems to have been edited incorrectly by someone, the link is now valid...

gurkensalat gravatar imagegurkensalat (Apr 24 '15)edit

Link is valid, but "Not Found" is only what i can see on that page

KirillTim gravatar imageKirillTim (Apr 26 '15)edit

didnt notice that one, updated:)

gurkensalat gravatar imagegurkensalat (Apr 26 '15)edit

Question Tools

Stats

Asked: Apr 18 '15

Seen: 229 times

Last updated: Apr 26