3

In Ubuntu 16.04 I have 2 input methods (keyboard layouts) configured, CZ (default) and US. Also I have enabled different input methods for different windows. This configuration works as expected and so far I like it, but I would like to modify its behavior in one special case.

I would like to set the initial layout of a terminal window (GNOME Terminal) to US. The problem is that now, when I open the terminal window, a default language or the language of the previous window (according to the configuration) is used, which is not US every time.

I tried to add setxkbmap -layout us to ~/.bashrc, it changed the layout, but the layout indicator (in the top right corner) did not change and when the terminal window lost and regained focus, the modification done by setxkbmap was no longer applied. It seems to me that the daemon which takes care of managing per-window layouts didn't register the modificatin by setxkbmap. A command which tells the daemon to use a given layout for the actual window would probably solve my problem.

bedrorom
  • 133

2 Answers2

1

Given that you enabled different input methods for different windows, it should be sufficient to replace the setxkbmap command in ~/.bashrc with:

gsettings set org.gnome.desktop.input-sources current 0

Please note that the number is the order number of the input sources you added, and the 0 (zero) is just an example which presupposes that English (US) is the the first input source item. Change it to 1 if English (US) is the second one etc.

Gunnar Hjalmarsson
  • 33,540
  • 3
  • 64
  • 94
0

You can even set your available layouts with

gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'de+neo_qwertz'), ('xkb', 'de')]"

In this case its the German layout with neoqwertz and the normal German layout.

I needed this to set my layout on ArchLinux with Gnome 40, because settings crashes after activating show-all-sources and navigating to Settings → Keyboard → +

gsettings set org.gnome.desktop.input-sources show-all-sources true
Darkproduct
  • 101
  • 2