diff --git a/README.md b/README.md index 9c0a71e..eea06fa 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,8 @@ If you use a lot of wallpapers, consider unloading those that you no longer need You can issue a `hyprctl hyprpaper unload [PATH]` to do that. +You can also issue a `hyprctl hyprpaper unload all` to unload all inactive wallpapers. +
For other compositors, the socket works like socket1 of Hyprland, and is located in `/tmp/hypr/.hyprpaper.sock` (this path only when Hyprland is not running!) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 29253eb..cd468e6 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -112,6 +112,11 @@ void CConfigManager::parseKeyword(const std::string& COMMAND, const std::string& } void CConfigManager::handleWallpaper(const std::string& COMMAND, const std::string& VALUE) { + if (VALUE == "all") { + handleUnloadAll(COMMAND, VALUE); + return; + } + if (VALUE.find_first_of(',') == std::string::npos) { parseError = "wallpaper failed (syntax)"; return; @@ -173,3 +178,21 @@ void CConfigManager::handleUnload(const std::string& COMMAND, const std::string& g_pHyprpaper->unloadWallpaper(WALLPAPER); } + +void CConfigManager::handleUnloadAll(const std::string& COMMAND, const std::string& VALUE) { + for (auto&[name, target] : g_pHyprpaper->m_mWallpaperTargets) { + + bool exists = false; + for (auto&[mon, target2] : g_pHyprpaper->m_mMonitorActiveWallpaperTargets) { + if (&target == target2) { + exists = true; + break; + } + } + + if (exists) + continue; + + g_pHyprpaper->unloadWallpaper(name); + } +} diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 426bb2a..13b2d44 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -20,6 +20,7 @@ private: void handleWallpaper(const std::string&, const std::string&); void handlePreload(const std::string&, const std::string&); void handleUnload(const std::string&, const std::string&); + void handleUnloadAll(const std::string&, const std::string&); friend class CIPCSocket; };