When you are trying out new programs, you might not want to edit ~/.Xdefaults or even re-merge ~/.Xresources just to test out settings, that’s when the XENVIRONMENT environment variable comes in handy.

According to Xlib Programming Manual:

On a POSIX-conformant system, this file is $HOME/.Xdefaults. After loading these defaults, XGetDefault() merges additional defaults specified by the XENVIRONMENT environment variable. If XENVIRONMENT is defined, it contains a full path name for the additional resource file. If XENVIRONMENT is not defined, XGetDefault() looks for $HOME/.Xdefaults-name, where name specifies the name of the machine on which the application is running.

Say your testing resource is at ~/tmp/testing-foobar-defaults, then you would invoke the program like

$ XENVIRONMENT=$HOME/tmp/test-foobar-defaults foobar-command

From excerpt above, you can even have per-machine (or host) based resource settings. If you have your dotfiles propagating or synchronizing all over the machines that you work on, it’d be easy to maintain and have different settings to fit each machine’s environment:

~/.Xdefaults-lab123
~/.Xdefaults-homeoffice
~/.Xdefaults-worksomething