Re: What's the Right Way to read resources on X startup?
Re: What's the Right Way to read resources on X startup?
- Subject: Re: What's the Right Way to read resources on X startup?
- From: raf <email@hidden>
- Date: Mon, 21 Jun 2010 12:55:09 +1000
Richard Cobbe wrote:
> I'm running XQuartz 2.5.1_rc1 on MacOS 10.6.4. What's the Right Way (tm)
> to load X resources on startup? I'm particularly interested in avoiding a
> race condition between the xresources load and the start of the initial
> client application.
>
> In more detail:
>
> I have some resource settings, some of which affect xterm, in ~/.Xresources
> -- the location where /opt/X11/lib/X11/xinit/xinitrc appears to look for
> them.
>
> I generally start X by running a Unix executable that I wrote myself, which
> sets up a specific environment, then forks and execs /opt/X11/bin/xterm in
> the background, then immediately terminates. (Full source and additional
> details of why I'm fiddling with the environment are available on request.)
>
> I've added this binary to the programs that start automatically when I log
> in. On login, then, this executable gets run, and it runs xterm, which in
> term causes launchd to start XQuartz. However, sometimes the xterm starts
> before loading the X resources in ~/.Xresources, and sometimes it starts
> afterward.
>
> In cases where the xterm starts before xrdb is run, I can just type "xterm
> & exit" at the bash prompt in that terminal, and this new xterm clearly
> picks up the resource settings. So they're definitely getting loaded at X
> startup, it's just a race condition as to whether xrdb or xterm runs first.
>
> What's the best way to avoid this? I could put a call to sleep in the
> executable that starts the xterm, but that's ugly and not particularly
> robust.
>
> In earlier attempts to get this working, I had scripts in
> ~/.xinitrc.d/00-resources.sh and ~/.xinitrc.d/99-xterm.sh that would
> respectively load the resources and start the initial xterm. In this case,
> I had XQuartz.app in my login items rather than the start-the-xterm
> program. The race condition happened here as well.
>
> Thanks,
> Richard
hi richard,
what i've always done on all x11 systems is to have my own
~/.xinitrc (or ~/.xsession) file that gets run instead of
the systetem's default xinitrc. then you get to control the
sequence of things.
for example, my ~/.xinitrc does the following
(among other things):
- determine my preferred default xterm sizes based on monitor dimensions
- load resources (xrdb -merge ~/.xresources)
- remap keyboard (xmodmap ~/.xmodmaprc)
- set background image (xsetroot -bitmap ...)
- start ssh agent (eval `ssh-agent -k`)
- contruct the "desktop" (xterm...&, xterm...&, sunclock...&, whatever...&)
- run the window manager (twm - not in the background)
# everything below here runs after i quit the window manager to "log out" of x11
- kill ssh-agent (ssh-agent -k)
- kill the processes started above
- undo the keyboard remapping done above (xmodmap ~/.xmodmaprs)
so the xterms (or whatever) are always started after xrdb has run.
bear in mind that for some reason i don't understand, ever
since i started using macosx-10.6 a few weeks ago, the
xmodmap command doesn't seen to have any effect when run
from my ~/.xinitrc file (it used to on macosx-10.4). i have
to run it again manualy once x has started up and then it
works. but xrdb -merge works from the ~/.xinitrc file.
cheers,
raf
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden