diff --git a/hyprpm/hyprpm.usage b/hyprpm/hyprpm.usage index 24e631c5..c38bdd62 100644 --- a/hyprpm/hyprpm.usage +++ b/hyprpm/hyprpm.usage @@ -14,7 +14,7 @@ hyprpm []... | (list) "List all installed plugins" | (enable ) "Load a plugin" | (disable ) "Unload a plugin" - | (reload) "Reload all plugins" + | (reload) "Reload plugins to match the enabled/disabled state. Use -f to force reload." ; ::= {{{ hyprpm list | awk '/Plugin/{print $4}' }}}; diff --git a/hyprpm/src/core/PluginManager.cpp b/hyprpm/src/core/PluginManager.cpp index a3bd5a09..80d0a402 100644 --- a/hyprpm/src/core/PluginManager.cpp +++ b/hyprpm/src/core/PluginManager.cpp @@ -780,7 +780,7 @@ bool CPluginManager::disablePlugin(const std::string& name) { return ret; } -ePluginLoadStateReturn CPluginManager::ensurePluginsLoadState() { +ePluginLoadStateReturn CPluginManager::ensurePluginsLoadState(bool forceReload) { if (headersValid() != HEADERS_OK) { std::println(stderr, "\n{}", failureString("headers are not up-to-date, please run hyprpm update.")); return LOADSTATE_HEADERS_OUTDATED; @@ -841,9 +841,9 @@ ePluginLoadStateReturn CPluginManager::ensurePluginsLoadState() { // (and Hyprland needs to restart) bool hyprlandVersionMismatch = false; - // unload disabled plugins + // unload disabled plugins (or all if forceReload is true) for (auto const& p : loadedPlugins) { - if (!enabled(p)) { + if (forceReload || !enabled(p)) { // unload if (!loadUnloadPlugin(HYPRPMPATH / repoForName(p) / (p + ".so"), false)) { std::println("{}", infoString("{} will be unloaded after restarting Hyprland", p)); @@ -859,7 +859,7 @@ ePluginLoadStateReturn CPluginManager::ensurePluginsLoadState() { if (!p.enabled) continue; - if (std::find_if(loadedPlugins.begin(), loadedPlugins.end(), [&](const auto& other) { return other == p.name; }) != loadedPlugins.end()) + if (!forceReload && std::find_if(loadedPlugins.begin(), loadedPlugins.end(), [&](const auto& other) { return other == p.name; }) != loadedPlugins.end()) continue; if (!loadUnloadPlugin(HYPRPMPATH / repoForName(p.name) / p.filename, true)) { diff --git a/hyprpm/src/core/PluginManager.hpp b/hyprpm/src/core/PluginManager.hpp index 7502cc04..a99d8e6e 100644 --- a/hyprpm/src/core/PluginManager.hpp +++ b/hyprpm/src/core/PluginManager.hpp @@ -51,7 +51,7 @@ class CPluginManager { bool enablePlugin(const std::string& name); bool disablePlugin(const std::string& name); - ePluginLoadStateReturn ensurePluginsLoadState(); + ePluginLoadStateReturn ensurePluginsLoadState(bool forceReload = false); bool loadUnloadPlugin(const std::string& path, bool load); SHyprlandVersion getHyprlandVersion(bool running = true); diff --git a/hyprpm/src/main.cpp b/hyprpm/src/main.cpp index 103132f9..887bb436 100644 --- a/hyprpm/src/main.cpp +++ b/hyprpm/src/main.cpp @@ -154,7 +154,7 @@ int main(int argc, char** argv, char** envp) { if (ret != LOADSTATE_OK) return 1; } else if (command[0] == "reload") { - auto ret = g_pPluginManager->ensurePluginsLoadState(); + auto ret = g_pPluginManager->ensurePluginsLoadState(force); if (ret != LOADSTATE_OK && notify) { switch (ret) {