View previous topic :: View next topic |
Author |
Message |
alex.blackbit Advocate
Joined: 26 Jul 2005 Posts: 2397
|
Posted: Wed Oct 29, 2014 2:03 pm Post subject: Xresources and environment variables |
|
|
Hi,
I have a slight problem in understanding the interaction between the X server resource database and environment variables.
My ~/.Xresources looks rather common, there is one statement though where I would like to be able to use an environment variable.
That's because I store my dotfiles, including ~/.Xresources in a git repository and use them on several machines.
Not on all machines is my home directory in the same location, therefore it would be nice to be able to use $HOME.
This is the particular line: Code: | URxvt.perl-lib: $HOME/dotfiles/submodules/urxvt-perls:$HOME/dotfiles/submodules/urxvt-font-size |
The resources I found on the WWW contradict each other and I wasn't able to work it out myself.
A workaround is to use the preprocessor and do Code: | $ xrdb -DENV_HOME="${HOME}" -load .Xresources |
Then the string in the ~/.Xresources reads ENV_HOME instead of $HOME of course.
I guess there is a nicer way to do this though.
Thanks in advance for all suggestions. |
|
Back to top |
|
|
i92guboj Bodhisattva
Joined: 30 Nov 2004 Posts: 10315 Location: Córdoba (Spain)
|
Posted: Thu Oct 30, 2014 7:37 am Post subject: |
|
|
As far as I know you can't do that, at least not in the sense you seem to imply.
This file is not parsed by a shell, so there's no variable substitution. It admits some wildcard-ing, which, coincidentally, resemble those of the shell. So, you can use something like "clock*background" to match more than one target. But no variable expansion.
As far as I know (though admittedly I didn't look at the code myself) this is stored (and then served) by the X server as a list of strings. It's xlib the one that "serve" the requested setting to the application requesting it, which essentially receives the same string you have put in the file. Then, it is up to the application how that string is interpreted (so, it should be possible for the application to do the variable expansion, I guess).
One thing you can try and that might work for some applications is to swap '$HOME' with '~'. Again, whether it will work or not will depend on the application, if I am not horribly mistaken. |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Fri Oct 31, 2014 2:17 am Post subject: |
|
|
The preprocessor seems like the nicest way to do it if you really want it in .Xresources, though there's also the option of setting $URXVT_PERL_LIB in your xsession scripts. |
|
Back to top |
|
|
alex.blackbit Advocate
Joined: 26 Jul 2005 Posts: 2397
|
Posted: Sun Nov 02, 2014 11:19 pm Post subject: |
|
|
I'll stick with the preprocessor.
Thanks for your thoughts. |
|
Back to top |
|
|
|