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

nass
  • 548
  • 4
  • 10
  • 24

1 Answers1

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)

Nikolaidis Fotis
  • 1,994
  • 11
  • 13
  • i'll try it and get back to you. – nass Oct 23 '12 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 '12 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 '12 at 11:20
  • ok ... yes ... it depends on the configuration, but the general idea is to put it in an X init script :> – Nikolaidis Fotis Oct 23 '12 at 11:33