I figured out a much more easy way to do it. Its my fault for not reading the loop right. I changed it if it is Dvorak, then change it to US, if it is US, then change it to Esperanto. If it is Esperanto, change it to Dvorak, else change it to Esperanto again!
I have this mapped to my F2 key with xbindkeys. Now if I press F2 I can get the Dvorak, press again it is Qwerty, a 3rd time actually brings the Esperanto keyboard, and pressing it again goes back to Dvorak! A magic keymapping button! Thanks for your help anyway though!
if [ "$keyboard_layout" == "Dvorak" ]
echo "Us" > .keyboard_status.txt
elif [ "$keyboard_layout" == "Us" ]
echo "Esperanto" > .keyboard_status.txt
elif [ "$keyboard_layout" == "Esperanto" ]
echo "Dvorak" > .keyboard_status.txt
echo "Espo" > .keyboard_status.txt