added unload all

This commit is contained in:
vaxerski 2022-11-26 18:27:19 +00:00
parent e5d64c0be9
commit 3571e20b55
3 changed files with 26 additions and 0 deletions

View file

@ -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.
<br/>
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!)

View file

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

View file

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