How can I change the keyboard layout through the terminal?

I found the solution using the xkbswitch utility.