XQuartz: user / environment when executing xinit? (XMonad, xmodmap, etc.) I'm running XMonad with XQuartz on an 11,3 Macbook Prop Retina. My .xinitrc looks as follow:

[[ -f ~/.Xdefaults ]] &amp;&amp; xrdb -load ~/.Xdefaults
export LANG="en_CA.UTF-8"
xmodmap /Users/xxxxxxx/.xmodmarc
cd $HOME
/Users/xxxxxxxx/Library/Haskell/bin/xmonad


I've noticed that both the LANG export and the xmodmap are being called, but their effects are not persisting. If I throw some env &gt;&gt; tmp.txt in there I can see that it's a different environment than when I finally reach a terminal, and I suspect perhaps even a different user that is calling xinit. 

My Questions


what user or environment is actually calling xinit when you startup XQuartz?
where is the appropriate place to put xmodmap so that it's called once, and only once, when XQuartz is started?
How do I get the LANG set once, and only once, as an environment variable when I start XQuartz (I need it for unicode support)


Thank you!
What user/env is actually calling xinit when you start XQuartz?

Under Linux, this would be the user that you logged in as; I'd suspect that it's probably the same for Mac OS X.  As for the environment, whatever the current environment is when you run xinit, that will be the environment that XQuartz runs with, excepting changes to the environment done within one of the files that XQuartz reads when it starts up.

Where should I put xmodmap so that it's called once, and only once, when XQuartz is started?

To create your own custom map/table and store it in a configuration file, run:

xmodmap -pke &gt; ~/.Xmodmap


Make the desired changes to ~/.Xmodmap and then test the new configuration with:

xmodmap ~/.Xmodmap


To active your custom table when starting Xorg, that is XQuartz, add the following to your ~/.xinitrc

[ -s ~/.Xmodmap ] &amp;&amp; xmodmap ~/.Xmodmap # you can also try using `[[ -s ~/.Xmodmap ]] &amp;&amp; xmodmap ~/.Xmodmap`


How do I get the LANG set once, and only once, as an environment variable when I start XQuartz (I need it for unicode support)

To set LANG, simply add one of the following to your ~/.xinitrc

[[ -z "$LANG" ]] &amp;&amp; LANG=&lt;VALUE&gt; # only sets LANG, if LANG is empty
LANG=&lt;VALUE&gt; # sets LANG regardless of whether it is or is not empty