mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-11-16 22:25:59 +01:00
internal: Add handler "reload" to do a change of wallpaper by one hyprctl exec (#173)
* Add handler "reload" to do a change of wallpaper by one hyprctl execution * fixed contain parameter handling in "handleReload"
This commit is contained in:
parent
678d0e8959
commit
2c57525de8
2 changed files with 35 additions and 1 deletions
|
@ -124,6 +124,39 @@ static Hyprlang::CParseResult handleUnload(const char* C, const char* V) {
|
||||||
return Hyprlang::CParseResult{};
|
return Hyprlang::CParseResult{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Hyprlang::CParseResult handleReload(const char* C, const char* V) {
|
||||||
|
const std::string COMMAND = C;
|
||||||
|
const std::string VALUE = V;
|
||||||
|
|
||||||
|
auto WALLPAPER = g_pConfigManager->trimPath(VALUE.substr(VALUE.find_first_of(',') + 1));
|
||||||
|
|
||||||
|
if (WALLPAPER.find("contain:") == 0) {
|
||||||
|
WALLPAPER = WALLPAPER.substr(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto preloadResult = handlePreload(C, WALLPAPER.c_str());
|
||||||
|
if (preloadResult.error)
|
||||||
|
return preloadResult;
|
||||||
|
|
||||||
|
auto MONITOR = VALUE.substr(0, VALUE.find_first_of(','));
|
||||||
|
|
||||||
|
if (MONITOR.empty()) {
|
||||||
|
for (auto& m : g_pHyprpaper->m_vMonitors) {
|
||||||
|
auto OLD_WALLPAPER = g_pHyprpaper->m_mMonitorActiveWallpapers[m->name];
|
||||||
|
g_pHyprpaper->unloadWallpaper(OLD_WALLPAPER);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
auto OLD_WALLPAPER = g_pHyprpaper->m_mMonitorActiveWallpapers[MONITOR];
|
||||||
|
g_pHyprpaper->unloadWallpaper(OLD_WALLPAPER);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto wallpaperResult = handleWallpaper(C, V);
|
||||||
|
if (wallpaperResult.error)
|
||||||
|
return wallpaperResult;
|
||||||
|
|
||||||
|
return Hyprlang::CParseResult{};
|
||||||
|
}
|
||||||
|
|
||||||
CConfigManager::CConfigManager() {
|
CConfigManager::CConfigManager() {
|
||||||
// Initialize the configuration
|
// Initialize the configuration
|
||||||
// Read file from default location
|
// Read file from default location
|
||||||
|
@ -142,6 +175,7 @@ CConfigManager::CConfigManager() {
|
||||||
config->registerHandler(&handleUnload, "unload", {.allowFlags = false});
|
config->registerHandler(&handleUnload, "unload", {.allowFlags = false});
|
||||||
config->registerHandler(&handlePreload, "preload", {.allowFlags = false});
|
config->registerHandler(&handlePreload, "preload", {.allowFlags = false});
|
||||||
config->registerHandler(&handleUnloadAll, "unloadAll", {.allowFlags = false});
|
config->registerHandler(&handleUnloadAll, "unloadAll", {.allowFlags = false});
|
||||||
|
config->registerHandler(&handleReload, "reload", {.allowFlags = false});
|
||||||
|
|
||||||
config->commence();
|
config->commence();
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ bool CIPCSocket::mainThreadParseRequest() {
|
||||||
m_bRequestReady = false;
|
m_bRequestReady = false;
|
||||||
|
|
||||||
// config commands
|
// config commands
|
||||||
if (copy.find("wallpaper") == 0 || copy.find("preload") == 0 || copy.find("unload") == 0) {
|
if (copy.find("wallpaper") == 0 || copy.find("preload") == 0 || copy.find("unload") == 0 || copy.find("reload") == 0) {
|
||||||
|
|
||||||
const auto RESULT = g_pConfigManager->config->parseDynamic(copy.substr(0, copy.find_first_of(' ')).c_str(), copy.substr(copy.find_first_of(' ') + 1).c_str());
|
const auto RESULT = g_pConfigManager->config->parseDynamic(copy.substr(0, copy.find_first_of(' ')).c_str(), copy.substr(copy.find_first_of(' ') + 1).c_str());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue