aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--example/examplePlugin/main.cpp6
-rw-r--r--src/config/ConfigManager.cpp10
-rw-r--r--src/config/ConfigManager.hpp2
-rw-r--r--src/plugins/PluginSystem.cpp3
4 files changed, 19 insertions, 2 deletions
diff --git a/example/examplePlugin/main.cpp b/example/examplePlugin/main.cpp
index 589c99c0..560af387 100644
--- a/example/examplePlugin/main.cpp
+++ b/example/examplePlugin/main.cpp
@@ -77,8 +77,12 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
static const auto METHODS = HyprlandAPI::findFunctionsByName(PHANDLE, "processMouseDownNormal");
g_pMouseDownHook = HyprlandAPI::createFunctionHook(PHANDLE, METHODS[0].address, (void*)&hkProcessMouseDownNormal);
+ static auto* const PBORDERCOLOR = HyprlandAPI::getConfigValue(PHANDLE, "plugin:example:border_color");
+
// fancy notifications
- HyprlandAPI::addNotificationV2(PHANDLE, {{"text", "Example hint"}, {"time", (uint64_t)10000}, {"color", CColor(0.2, 0.2, 0.9, 1.0)}, {"icon", ICON_HINT}});
+ HyprlandAPI::addNotificationV2(
+ PHANDLE,
+ {{"text", "Example hint, color " + std::to_string(PBORDERCOLOR->intValue)}, {"time", (uint64_t)10000}, {"color", CColor{PBORDERCOLOR->intValue}}, {"icon", ICON_HINT}});
// Enable our hooks
g_pFocusHook->hook();
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 1bea33b5..b5fcf0fa 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -371,8 +371,10 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s
CONFIGENTRY = &it->second;
}
- if (!CONFIGENTRY)
+ if (!CONFIGENTRY) {
+ m_vFailedPluginConfigValues.emplace_back(std::make_pair<>(COMMAND, VALUE));
return; // silent ignore
+ }
} else {
CONFIGENTRY = &configValues.at(COMMAND);
}
@@ -1458,6 +1460,7 @@ void CConfigManager::loadConfigLoadVars() {
setDefaultAnimationVars(); // reset anims
m_vDeclaredPlugins.clear();
m_dLayerRules.clear();
+ m_vFailedPluginConfigValues.clear();
// paths
configPaths.clear();
@@ -2179,6 +2182,11 @@ void CConfigManager::addPluginConfigVar(HANDLE handle, const std::string& name,
}
(*CONFIGMAPIT->second)[name] = value;
+
+ if (const auto IT = std::find_if(m_vFailedPluginConfigValues.begin(), m_vFailedPluginConfigValues.end(), [&](const auto& other) { return other.first == name; });
+ IT != m_vFailedPluginConfigValues.end()) {
+ configSetValueSafe(IT->first, IT->second);
+ }
}
void CConfigManager::removePluginConfig(HANDLE handle) {
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index 6556945c..d5cd77db 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -252,6 +252,8 @@ class CConfigManager {
std::vector<std::pair<std::string, std::string>> environmentVariables;
+ std::vector<std::pair<std::string, std::string>> m_vFailedPluginConfigValues; // for plugin values of unloaded plugins
+
// internal methods
void setDefaultVars();
void setDefaultAnimationVars();
diff --git a/src/plugins/PluginSystem.cpp b/src/plugins/PluginSystem.cpp
index 040cfcf1..d550f7d5 100644
--- a/src/plugins/PluginSystem.cpp
+++ b/src/plugins/PluginSystem.cpp
@@ -112,6 +112,9 @@ void CPluginSystem::unloadPlugin(const CPlugin* plugin, bool eject) {
Debug::log(LOG, " [PluginSystem] Plugin %s unloaded.", plugin->name.c_str());
std::erase_if(m_vLoadedPlugins, [&](const auto& other) { return other->m_pHandle == plugin->m_pHandle; });
+
+ // reload config to fix some stuf like e.g. unloadedPluginVars
+ g_pConfigManager->m_bForceReload = true;
}
void CPluginSystem::unloadAllPlugins() {