hyprpm: add an option to force reload all plugins (#8883)

This commit is contained in:
Tuur Vanhoutte 2024-12-30 00:09:17 +01:00 committed by GitHub
parent deb077c346
commit 5b37d53992
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 7 additions and 7 deletions

View file

@ -14,7 +14,7 @@ hyprpm [<FLAGS>]... <ARGUMENT>
| (list) "List all installed plugins"
| (enable <PLUGINS>) "Load a plugin"
| (disable <PLUGINS>) "Unload a plugin"
| (reload) "Reload all plugins"
| (reload) "Reload plugins to match the enabled/disabled state. Use -f to force reload."
;
<PLUGINS> ::= {{{ hyprpm list | awk '/Plugin/{print $4}' }}};

View file

@ -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)) {

View file

@ -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);

View file

@ -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) {