Thanks for the response Mike. I'm not quite sure if I see the value of
defining an alias since I don't mind writing out the whole command in
the shell script that will be calling it.

Would everyone agree then that using a file as a global variable is the
best way to transcend the scope of the shell?

This is the script:
#!/bin/bash
CURMAP=`cat ~/prog/kbmaplaunch/map`
if [ $CURMAP == "dvorak" ]
then
 echo "us" > ~/prog/kbmaplaunch/map
 setxkbmap us;
else
 echo "dvorak" > ~/prog/kbmaplaunch/map
 setxkbmap dvorak;
fi

----- Original message -----
From: "Mike Miller" <mbmiller at taxa.epi.umn.edu>
To: "Isaac Atilano" <aristophrenic at warpmail.net>
Date: Wed, 16 Nov 2005 18:17:26 -0600 (CST)
Subject: Re: [tclug-list] environment variables

On Wed, 16 Nov 2005, Isaac Atilano wrote:

> 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.


If you use a script to change an environment variable, it will be
changed 
only within the subshell of the script and it will not change the 
environment from which you called the script.

You need to use an alias.  Put this line in your .bashrc:

alias curmap="CURMAP=value"

Just put your value in there instead of "value."  Then when you enter 
"curmap" (without the quotes), it will sent your environment variable.

I can't see how anything will carry to *parent* shells.  Your script
won't 
do it and neither will this.

Mike