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

Posted by nass on Server Fault See other posts from Server Fault or by nass
Published on 2012-10-23T08:14:47Z Indexed on 2012/10/23 11:04 UTC
Read the original article Hit count: 299

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 other way?

Thank you for your help

© Server Fault or respective owner

Related posts about bash

Related posts about environment-variables