Skip to content

Commit

Permalink
os/xdg: Clarify why $HOME/.local/share/fonts isn't unconditionally added
Browse files Browse the repository at this point in the history
  • Loading branch information
robinlinden committed Nov 23, 2023
1 parent 403de1d commit f462845
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions os/xdg_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ namespace os {

std::vector<std::string> font_paths() {
std::vector<std::string> paths{};

char const *home = std::getenv("HOME");
if (char const *xdg_data_home = std::getenv("XDG_DATA_HOME")) {
paths.push_back(xdg_data_home + "/fonts"s);
} else if (home != nullptr) {
// $HOME/.local/share/ is the default XDG_DATA_HOME, so we only add this
// path if XDG_DATA_HOME is not set.
paths.push_back(home + "/.local/share/fonts"s);
}

if (char const *home = std::getenv("HOME")) {
if (paths.empty()) {
paths.push_back(home + "/.local/share/fonts"s);
}
if (home != nullptr) {
paths.push_back(home + "/.fonts"s);
}

Expand Down

0 comments on commit f462845

Please sign in to comment.