how to check in a bash script where the shell is run from

view story

http://linuxexchange.org – hello everyone, I am fuzzy about how to set a command in a script to be run only when the shell is running within an X session. basically, in ~/.bashrc I set my keyboard maps as setxkbmap -layout 'us,gr' -variant 'altgr-intl,extended' -option grp:alt_shift_toggle If I am connecting through putty , or otherwise, and i just open a command prompt window, I DONT want this command to run. If on the other hand, i have an X session running (locally or remotely) I want this command to run. how can I do this checking in a bash script? Is there a bash environment variable I can be looking at? some ot (HowTos)