setxkbmap resets in ubuntu 13.10

Gnome

Gnome preserve xkb options.

  1. Use dconf-editor → Follow path /org/gnome/desktop/input-sources

  2. Put layouts needed in sources, example:

    [('xkb','us'),('xkb','ara')]
    
  3. Add setxkbmap options to xkb-options, example:

    ['grp:rshift_toggle', 'grp:rctrl_switch']
    

    enter image description here

Unity & Gnome

xkb setting seems to be reset by Unity/Gnome settings daemon (periodically or when clicked to change layout) or when layout switch shortcuts used.

The above the method may not work. So this should disable completely the settings daemon layout control capability. Tested on Ubuntu Unity 15.10 .

  1. Rename the keyboard plugin of settings daemon to disable it.

    sudo mv /usr/lib/unity-settings-daemon-1.0/libkeyboard.so /usr/lib/unity-settings-daemon-1.0/libkeyboard.so.disabled
    
  2. Restart the settings daemon

    restart unity-settings-daemon
    

Note:

  • Ubuntu <= 13.10, Gnome & Unity uses same daemon (gnome-settings-daemon).
  • Ubuntu >=14.10, Gnome has gnome-settings-daemon & Unity has unity-settings-daemon