I wrote a shell script that toggles my keyboard mapping in my X session between us and dvorak using setxkbmap. I run it through a button I created on my desktop panel. I originally tried exporting an environment variable to use as the toggle flag but then found out that changes to the variable are not carried over to parent shells (duh!) thus making my script worthless. To solve this I created a file that contains one line, namely the toggle value and I read the value with the command: CURMAP=`cat file` I then check that value to figure whether I should set the keyboard to us or dvorak. I then overwrite the file with the new value. Since I don't have much experience shell scripting I guess there must be a better way of doing this (namely without file i/o) and am wondering if anyone can give me any tips as to how a real shell guru might accomplish this task.