Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Xresources and environment variables
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
alex.blackbit
Advocate
Advocate


Joined: 26 Jul 2005
Posts: 2397

PostPosted: Wed Oct 29, 2014 2:03 pm    Post subject: Xresources and environment variables Reply with quote

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
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Thu Oct 30, 2014 7:37 am    Post subject: Reply with quote

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
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Fri Oct 31, 2014 2:17 am    Post subject: Reply with quote

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
View user's profile Send private message
alex.blackbit
Advocate
Advocate


Joined: 26 Jul 2005
Posts: 2397

PostPosted: Sun Nov 02, 2014 11:19 pm    Post subject: Reply with quote

I'll stick with the preprocessor.
Thanks for your thoughts.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum