Your biggest problem is using exec too freely; Code: exec command replaces the current shell process with command. This is not what you want. Also, you don't need the xterms at all. You can launch whatever keyboard directly from Personal Menu
exec command