Set X keyboard layout permanently

1. terminal

Edit /etc/rc.local and set:

KEYMAP=es
loadkeys es

2. Xorg

Edit /etc/X11/xorg.conf.d/10-keyboard.conf

Section "InputClass"
        Identifier "keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "es"
EndSection