Can't add more than four keyboard layouts

I can't add more than 4 keyboard layouts on my ubuntu. It just won't let me add more. And I in need of at least 4 more. Anyone else encountered this problem and can give me some advice? Thanks in advance :)


Solution 1:

This is a known bug/limitation. The only workaround is to set up a shortcut to a script that switches between sets of keyboard layouts.

Based on this post on UF.org:

  1. Setup the first four layouts, then run the following two commands in a terminal:

    gconftool-2 --get /desktop/gnome/peripherals/keyboard/kbd/layouts
    gsettings get org.gnome.libgnomekbd.keyboard layouts
    
  2. Setup the second four layouts, then again run the above commands.

  3. Now open the text editor gedit (press Super, type gedit, press Enter) and paste the following:

    #!/bin/bash
    layout_one="[de deadgraveacute,al,ara,be]"
    layout_one_dconf="['de\tdeadgraveacute', 'al', 'ara', 'be']"
    
    layout_two="[de deadgraveacute,ba,ph,gb]"
    layout_two_dconf="['de\tdeadgraveacute', 'ba', 'ph', 'gb']"
    
    current=$(gconftool-2 --get /desktop/gnome/peripherals/keyboard/kbd/layouts)
    
    if [ "$current" == "$layout_one" ]
    then
        new="$layout_two"
        new_dconf="$layout_two_dconf"
    else
        new="$layout_one"
        new_dconf="$layout_one_dconf"
    fi
    
    gconftool-2 --set --type list --list-type string /desktop/gnome/peripherals/keyboard/kbd/layouts "$new"
    gsettings set org.gnome.libgnomekbd.keyboard layouts "$new_dconf"
    

    Make sure to replace the layouts for layout_one, layout_one_dconf, layout_two, and layout_two_dconf in that script with the output from steps 1 and 2. If there's empty space in a layout name, make sure to use a tab character rather than spaces (just copy and paste from the terminal).

  4. Save it somewhere, e.g. /home/YOURUSERNAME/Documents/scripts/keyboard-layout-switch
  5. From a terminal, run:

    chmod +x ~/Documents/scripts/keyboard-layout-switch
    

    to make the script executable.

  6. Now you need to set a shortcut to call that script: press Super, type keyboard, press Enter.

  7. In the keyboard settings, go to the Shortcuts tab and on the left click on Custom Shortcuts.

  8. Click on the tiny + icon to create a new shortcut with:

    • Name: Change Keyboard Layouts
    • Command: /home/YOURUSERNAME/Documents/scripts/keyboard-layout-switch

    enter image description here

  9. Click on apply, then click on Disabled to set the desired shortcut:

    enter image description here

  10. You now should be able to switch between two sets of four keyboard layouts with the shortcut you set.