Skip to content
Permalink
Browse files

prefer RS_THEME_LOCAL_HOME if set

  • Loading branch information...
jmcphers committed Aug 19, 2019
1 parent ed04690 commit c0fdde2661a20ab51d3b448db0048ec559f0d263
Showing with 30 additions and 7 deletions.
  1. +30 −7 src/cpp/session/modules/SessionThemes.cpp
@@ -236,20 +236,30 @@ FilePath getGlobalCustomThemePath()
}

/**
* @brief Gets the location of custom themes that are installed for the current user (legacy RStudio
* 1.2 version)
* @brief Gets the location of custom themes from an environment variable.
*
* @return The location of custom themes that are installed for the current user.
* @return The location of custom themes defined by the environment variable, or an empty path if
* the variable is not set.
*/
FilePath getLegacyLocalCustomThemePath()
FilePath getEnvCustomThemePath()
{
using rstudio::core::FilePath;
const char* kLocalPathAlt = std::getenv("RS_THEME_LOCAL_HOME");
if (kLocalPathAlt)
{
return FilePath(kLocalPathAlt);
}

return FilePath();
}

/**
* @brief Gets the location of custom themes that are installed for the current user (legacy RStudio
* 1.2 version)
*
* @return The location of custom themes that are installed for the current user.
*/
FilePath getLegacyLocalCustomThemePath()
{
return module_context::userHomePath().childPath(".R/rstudio/themes/");
}

@@ -277,8 +287,21 @@ ThemeMap getAllThemes()
ThemeMap themeMap;
getThemesInLocation(getDefaultThemePath(), kDefaultThemeLocation, &themeMap);
getThemesInLocation(getGlobalCustomThemePath(), kGlobalCustomThemeLocation, &themeMap);
getThemesInLocation(getLegacyLocalCustomThemePath(), kLocalCustomThemeLocation, &themeMap);
getThemesInLocation(getLocalCustomThemePath(), kLocalCustomThemeLocation, &themeMap);

// Check for an explicit path set from an environment variable. If set, this overrides the
// less specific built-in/XDG defaults.
FilePath envPath = getEnvCustomThemePath();
if (envPath.empty())
{
// No specific theme path set from environment variable, use defaults
getThemesInLocation(getLegacyLocalCustomThemePath(), kLocalCustomThemeLocation, &themeMap);
getThemesInLocation(getLocalCustomThemePath(), kLocalCustomThemeLocation, &themeMap);
}
else
{
// Use the specific theme path set from the environment variable
getThemesInLocation(envPath, kLocalCustomThemeLocation, &themeMap);
}

return themeMap;
}

0 comments on commit c0fdde2

Please sign in to comment.
You can’t perform that action at this time.