Define a new MESA_USER_DRIRC environment variable to load a customized drirc file.
When the variable is not defined, nothing changes and the ${HOME}/.drirc file will be loaded. If the variable is set to a file, this file will be loaded instead of the the ${HOME}/.drirc. Example: MESA_USER_DRIRC=~/glthread.drirc glxgears If the variable is set to nothing, it avoids to load the ${HOME}/.drirc file. Example: MESA_USER_DRIRC= glxgears --- docs/envvars.html | 1 + src/mesa/drivers/dri/common/xmlconfig.c | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/docs/envvars.html b/docs/envvars.html index 653736565e..02b89bac9d 100644 --- a/docs/envvars.html +++ b/docs/envvars.html @@ -130,6 +130,7 @@ that variable is set), or else within .cache/mesa within the user's home directory. <li>MESA_GLSL - <a href="shading.html#envvars">shading language compiler options</a> <li>MESA_NO_MINMAX_CACHE - when set, the minmax index cache is globally disabled. +<li>MESA_USER_DRIRC - load a user defined drirc file. </ul> diff --git a/src/mesa/drivers/dri/common/xmlconfig.c b/src/mesa/drivers/dri/common/xmlconfig.c index fef007996e..dd4b46f3a4 100644 --- a/src/mesa/drivers/dri/common/xmlconfig.c +++ b/src/mesa/drivers/dri/common/xmlconfig.c @@ -988,7 +988,6 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info, int screenNum, const char *driverName) { char *filenames[2] = { SYSCONFDIR "/drirc", NULL}; - char *home; uint32_t i; struct OptConfData userData; @@ -999,14 +998,23 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info, userData.driverName = driverName; userData.execName = GET_PROGRAM_NAME(); - if ((home = getenv ("HOME"))) { - uint32_t len = strlen (home); - filenames[1] = malloc(len + 7+1); - if (filenames[1] == NULL) - __driUtilMessage ("Can't allocate memory for %s/.drirc.", home); - else { - memcpy (filenames[1], home, len); - memcpy (filenames[1] + len, "/.drirc", 7+1); + const char *userDrirc = getenv("MESA_USER_DRIRC"); + + if (userDrirc) { + filenames[1] = malloc(strlen(userDrirc) + 1); + strcpy(filenames[1], userDrirc); + } + else { + const char *home = getenv("HOME"); + if (home) { + uint32_t len = strlen (home); + filenames[1] = malloc(len + 7+1); + if (filenames[1] == NULL) + __driUtilMessage ("Can't allocate memory for %s/.drirc.", home); + else { + memcpy (filenames[1], home, len); + memcpy (filenames[1] + len, "/.drirc", 7+1); + } } } -- 2.11.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev