I'm writing a little bash script that will toggle the keymap. I am currently using "setxkbmap -print|grep -q $KBD1" to check the current keymap. It's working fine for this case but I am wondering if there is a command that returns the current keymap. I've read man pages for setxkbmap, xmodmap, etc but couldn't find anything.
#!/bin/bash KBD1=us KBD2=ca_enhanced if setxkbmap -print|grep -q $KBD1 then setxkbmap $KBD2 else setxkbmap $KBD1 fi