0

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

1 Answer 1

1

you can add it to ~/.xinitrc (when an X is about to start, whatever is included in this file is executed)

-or /etc/xinitrc for global -

the other way you can do it is to add the configuration inside xorg.conf (check how to change layout)

4
  • i'll try it and get back to you.
    – nass
    Oct 23, 2012 at 10:42
  • hmmm i'm running fluxbox. and ~/.xinitrc doesn't seem to be sourced..... same with global xinitrc. I am not even sure the xorg.conf folder will work at this point
    – nass
    Oct 23, 2012 at 11:08
  • hmm fluxbox does all starting up from ~/.fluxbox/startup. I put the command in there (and appended a &) and it works!
    – nass
    Oct 23, 2012 at 11:20
  • ok ... yes ... it depends on the configuration, but the general idea is to put it in an X init script :> Oct 23, 2012 at 11:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .