From 3571e20b55da7921a47d4910204b40ab1701b5c4 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 26 Nov 2022 18:27:19 +0000 Subject: [PATCH] added unload all --- README.md | 2 ++ src/config/ConfigManager.cpp | 23 +++++++++++++++++++++++ src/config/ConfigManager.hpp | 1 + 3 files changed, 26 insertions(+) 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; };