3

I am using two different keyboard layouts, English US and Hungarian. I use them interchangeably, sometimes I type in Hungarian, my native, but often I use the US layout, especially for the terminal. I usually change layout using SUPER+SPACE. I have found out that there is a way to make Ubuntu remember that individual keyboard layout settings for different windows, but this does not apply for applications.

What I would like is that even if my currently selected layout is Hungarian, whenever I fire up a terminal, it should be immediately changed to US for the terminal window, so I don't have to bother around with that.

Jacob Vlijm
  • 83,767
bp99
  • 141
  • 6
  • I am pretty sure we've answered this somewhere, I'll try to find it... – Jacob Vlijm Jan 05 '17 at 18:15
  • 2
    Please look here: http://askubuntu.com/questions/637148/how-to-disable-input-language-switching-in-terminal/637334#637334 Is that what you are looking for? The question was on 12.04, the answers however were not.. – Jacob Vlijm Jan 05 '17 at 18:18
  • I should have been able to find this... This is exactly what I've been looking for, I will try it out right now. Thanks. – bp99 Jan 05 '17 at 18:21
  • Don't feel bad about it, I can only find it because I remembered answering it. Please mention if either one of the answers there fits. If so, we can mark this one as a dupe. – Jacob Vlijm Jan 05 '17 at 18:22
  • Unfortunately, the script did not really work out... I've just tried it out and this happened:

    X Error of failed request: BadWindow (invalid Window parameter) Major opcode of failed request: 20 (X_GetProperty) Resource id in failed request: 0x4801275 Serial number of failed request: 20 Current serial number in output stream: 20 Traceback (most recent call last): File "set_language.py", line 94, in set_lang(to_set) NameError: name 'to_set' is not defined

    – bp99 Jan 05 '17 at 18:30
  • I will look into it, possibly the script needs an update. Will be back... – Jacob Vlijm Jan 05 '17 at 18:32
  • Well, the script could use some editing... working on it... – Jacob Vlijm Jan 05 '17 at 18:49
  • I will rewrite the script, there is too much that I would do differently these days. Will post tonight late or tomorrow. In the meantime, maybe Serg's works as you like? – Jacob Vlijm Jan 05 '17 at 19:15
  • screenshot

    Well, that escalated quickly :P

    – bp99 Jan 05 '17 at 19:22
  • Haha, it looks like both our scripts need an update. Will post tomorrow for sure. It shouldn't be that much work, but refreshing your mind into something you would write differently today is more time consuming than simply rewriting it. To be continued... – Jacob Vlijm Jan 05 '17 at 19:27
  • Sure, I am a beginner at programming , but I've started with C# :D I can understand how much time this thing consumes... I hope that I'll be able to become as good as you are once :D And thanks – bp99 Jan 05 '17 at 19:31
  • Hi bertalanp99, rewrote the script, see: http://askubuntu.com/a/637334/72216 – Jacob Vlijm Jan 06 '17 at 10:59
  • 1
    @bertalanp99 The file crashed because you tried to run a bash shell script with python. It's like telling cat to bark :D Proper way to run it would be bash script.sh. For 16.04 at least, there are options in Ubuntu settings there's a way to tell Ubuntu to remember different languages per window (see this: http://imgur.com/a/DbMxv) , so really you don't need a script. But if you really do want a script, feel free to look at this alternative: http://askubuntu.com/a/656671/295286 – Sergiy Kolodyazhnyy Jan 07 '17 at 12:56
  • @Serg Whoops :D After looking at Jacob's script, I didn't even really look into what your script includes, I thought it was written in Python as well... I couldn't find that option as of yet, but perhaps I'll check again. Thanks. – bp99 Jan 08 '17 at 22:06
  • @JacobVlijm Thank you, the non-script solution provided by Serg does not work, I'll use it. – bp99 Jan 08 '17 at 22:07
  • 2
  • @bertalanp99 Hi bert, I assume that implies my rewritten script works as you had in mind. I'll dupe this question then. The built-in option Serg mentions works, but only per window, so you need to set it everytime again on new windows :) – Jacob Vlijm Jan 09 '17 at 07:35

1 Answers1

1

Try xxkb.

From the manpage:

The xxkb program shows the current keyboard layout (an XKB group) and allows to switch it with a mouse click. It has some additional features. The xxkb remembers the layout for each application window and changes the keyboard state accordingly when the window gets a focus.