From 553b4474a76e44ca0cf94b311be367fe0cdad22c Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Wed, 23 Jun 2021 01:53:18 +0200 Subject: [PATCH] Respect $XDG_DATA_HOME when looking for binaries Since we're using the XDG base dir package in yabridgectl we were already doing this there, so it makes sense to also do this in yabridge itself even though it's very unlikely the user will have this set. --- CHANGELOG.md | 3 +++ src/plugin/utils.cpp | 8 ++++++-- src/plugin/utils.h | 9 +++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4a822e4..0532c40e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,9 @@ Versioning](https://semver.org/spec/v2.0.0.html). allocations in certain situations. This is related to the similar issue that got fixed with yabridge 3.3.0. A fix for this issue has also been upstreamed to the library. +- Respect `$XDG_DATA_HOME` when looking for yabridge's plugin host binaries + instead of hardcoding `~/.local/share/yabridge`. This matches the existing + behaviour in yabridgectl. ### Fixed diff --git a/src/plugin/utils.cpp b/src/plugin/utils.cpp index 34f6c33c..6ae09bae 100644 --- a/src/plugin/utils.cpp +++ b/src/plugin/utils.cpp @@ -373,8 +373,12 @@ std::vector get_augmented_search_path() { boost::this_process::path(); const bp::environment environment = boost::this_process::environment(); - if (auto home_directory = environment.find("HOME"); - home_directory != environment.end()) { + if (auto xdg_data_home = environment.find("XDG_DATA_HOME"); + xdg_data_home != environment.end()) { + search_path.push_back(fs::path(xdg_data_home->to_string()) / + "yabridge"); + } else if (auto home_directory = environment.find("HOME"); + home_directory != environment.end()) { search_path.push_back(fs::path(home_directory->to_string()) / ".local" / "share" / "yabridge"); } diff --git a/src/plugin/utils.h b/src/plugin/utils.h index a64b5a80..802e21ec 100644 --- a/src/plugin/utils.h +++ b/src/plugin/utils.h @@ -227,10 +227,11 @@ boost::filesystem::path generate_group_endpoint( /** * Return the search path as defined in `$PATH`, with `~/.local/share/yabridge` - * appended to the end. I'd rather not do this since more magic makes things - * harder to comprehend, but I can understand that modifying your login shell's - * `PATH` environment variable can be a big hurdle if you've never done anything - * like that before. And since this is the recommended installation location, it + * appended to the end. Even though it likely won't be set, this does respect + * `$XDG_DATA_HOME`. I'd rather not do this since more magic makes things harder + * to comprehend, but I can understand that modifying your login shell's `PATH` + * environment variable can be a big hurdle if you've never done anything like + * that before. And since this is the recommended installation location, it * makes sense to also search there by default. */ std::vector get_augmented_search_path();