mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-11-16 22:25:59 +01:00
Trim support for wallpaper path. (#29)
* Trim support for wallpaper path.
This commit is contained in:
parent
aefd63876d
commit
885212dedc
2 changed files with 10 additions and 1 deletions
|
@ -118,7 +118,7 @@ void CConfigManager::handleWallpaper(const std::string& COMMAND, const std::stri
|
|||
}
|
||||
|
||||
auto MONITOR = VALUE.substr(0, VALUE.find_first_of(','));
|
||||
auto WALLPAPER = VALUE.substr(VALUE.find_first_of(',') + 1);
|
||||
auto WALLPAPER = trimPath(VALUE.substr(VALUE.find_first_of(',') + 1));
|
||||
|
||||
bool contain = false;
|
||||
|
||||
|
@ -201,3 +201,11 @@ void CConfigManager::handleUnloadAll(const std::string& COMMAND, const std::stri
|
|||
for (auto& tu : toUnload)
|
||||
g_pHyprpaper->unloadWallpaper(tu);
|
||||
}
|
||||
|
||||
// trim from both ends
|
||||
std::string CConfigManager::trimPath(std::string path) {
|
||||
//trims whitespaces, tabs and new line feeds
|
||||
size_t pathStartIndex = path.find_first_not_of(" \t\r\n");
|
||||
size_t pathEndIndex = path.find_last_not_of(" \t\r\n");
|
||||
return path.substr(pathStartIndex, pathEndIndex - pathStartIndex + 1);
|
||||
}
|
|
@ -21,6 +21,7 @@ private:
|
|||
void handlePreload(const std::string&, const std::string&);
|
||||
void handleUnload(const std::string&, const std::string&);
|
||||
void handleUnloadAll(const std::string&, const std::string&);
|
||||
std::string trimPath(std::string path);
|
||||
|
||||
friend class CIPCSocket;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue