diff --git a/README.md b/README.md index 8ee8234..78fedd1 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ splash = true ``` -Preload will tell Hyprland to load a particular image (supported formats: png, jpg, jpeg, webp). Wallpaper will apply the wallpaper to the selected output (`monitor` is the monitor's name, easily can be retrieved with `hyprctl monitors`. You can leave it empty for a wildcard (aka fallback). You can also use `desc:` followed by the monitor's description without the (PORT) at the end) +Preload will tell Hyprland to load a particular image (supported formats: png, jpg, jpeg, webp). Wallpaper will apply the wallpaper to the selected output (`monitor` is the monitor's name, easily can be retrieved with `hyprctl monitors`. You can leave it empty to set all monitors without an active wallpaper. You can also use `desc:` followed by the monitor's description without the (PORT) at the end) You may add `contain:` before the file path in `wallpaper=` to set the mode to contain instead of cover: diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 21c66bb..cdf3672 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -36,24 +36,29 @@ static Hyprlang::CParseResult handleWallpaper(const char* C, const char* V) { return result; } - g_pHyprpaper->clearWallpaperFromMonitor(MONITOR); - g_pHyprpaper->m_mMonitorActiveWallpapers[MONITOR] = WALLPAPER; - g_pHyprpaper->m_mMonitorWallpaperRenderData[MONITOR].contain = contain; - - if (MONITOR.empty()) { + if (MONITOR.empty()) { //if the monitor string is empty we set all the empty monitors to the same wallpaper for (auto& m : g_pHyprpaper->m_vMonitors) { if (!m->hasATarget || m->wildcard) { + Debug::log(LOG, "Setting wallpaper for monitor %s", m->name); g_pHyprpaper->clearWallpaperFromMonitor(m->name); g_pHyprpaper->m_mMonitorActiveWallpapers[m->name] = WALLPAPER; g_pHyprpaper->m_mMonitorWallpaperRenderData[m->name].contain = contain; } } - } else { - const auto PMON = g_pHyprpaper->getMonitorFromName(MONITOR); - if (PMON) - PMON->wildcard = false; + return result; + } + + const auto PMON = g_pHyprpaper->getMonitorFromName(MONITOR); + if (!PMON){ //does monitor by name of MONITOR exist? + result.setError("wallpaper failed (no such monitor)"); + return result; } + g_pHyprpaper->clearWallpaperFromMonitor(MONITOR); //should be fine to keep using MONITOR instead of using PMON->name here + g_pHyprpaper->m_mMonitorActiveWallpapers[MONITOR] = WALLPAPER; + g_pHyprpaper->m_mMonitorWallpaperRenderData[MONITOR].contain = contain; + + PMON->wildcard = false; return result; }