daemon: optionally use plugin path from environment

This commit is contained in:
Jussi Kuokkanen 2023-09-24 23:43:47 +03:00
parent ec368cd76e
commit 3922d4d419

View File

@ -11,8 +11,17 @@ std::string Plugin::pluginPath() { return TC_PLUGIN_PATH; }
std::optional<std::vector<boost::shared_ptr<DevicePlugin>>> DevicePlugin::loadPlugins() {
std::vector<boost::shared_ptr<DevicePlugin>> retval;
// std::cout << pluginPath();
for (const fs::directory_entry &entry : fs::directory_iterator(Plugin::pluginPath())) {
std::string pluginPath;
const char *pluginPathEnv = std::getenv("TUXCLOCKER_PLUGIN_PATH");
// Use plugin path from environment if it exists
if (pluginPathEnv)
pluginPath = pluginPathEnv;
else
pluginPath = Plugin::pluginPath();
for (const fs::directory_entry &entry : fs::directory_iterator(pluginPath)) {
// Bleh, have to catch this unless I do more manual checks
try {
auto plugin = boost::dll::import_symbol<DevicePlugin>(