From 7690881a3694276dbd29d1a7424eab9198be4789 Mon Sep 17 00:00:00 2001 From: AnmiTaliDev Date: Sat, 15 Aug 2026 07:01:35 +0500 Subject: [PATCH] Add dwm desktop wallpaper support --- binding-mri/wallpaper-binding.cpp | 29 +++++++++++++++++++++++++++++ src/oneshot.cpp | 2 ++ 2 files changed, 31 insertions(+) diff --git a/binding-mri/wallpaper-binding.cpp b/binding-mri/wallpaper-binding.cpp index 3d408f6..fd0d289 100644 --- a/binding-mri/wallpaper-binding.cpp +++ b/binding-mri/wallpaper-binding.cpp @@ -58,6 +58,9 @@ static std::string originalBgMode = ""; // LXQT static std::string DBUS_SESSION_BUS_ADDRESS = ""; + // dwm (feh) + static std::string originalFehbgCmd = ""; + static bool originalFehbgExists = false; // Fallback settings static std::string fallbackPath; #endif @@ -113,6 +116,19 @@ } infile.close(); } + if (desktop == "dwm"){ + const char* homeC = SDL_getenv("HOME"); + if (!homeC) return; + std::string path = std::string(homeC) + "/.fehbg"; + std::ifstream infile(path); + if (infile) { + std::stringstream buffer; + buffer << infile.rdbuf(); + originalFehbgCmd = buffer.str(); + originalFehbgExists = !originalFehbgCmd.empty(); + infile.close(); + } + } //just reuse code :3 if (desktop == "lxqt"){ DBUS_SESSION_BUS_ADDRESS = SDL_getenv("DBUS_SESSION_BUS_ADDRESS"); @@ -462,6 +478,13 @@ end: if (status != 0) { Debug() << "bliat ono slomalos\n"; } + } else if (desktop == "dwm") { + std::string concatPath = gameDirStr + path; + std::string cmd = "feh --bg-scale \"" + concatPath + "\""; + int status = std::system(cmd.c_str()); + if (status != 0) { + Debug() << "bliat ono slomalos\n"; + } } else { std::ifstream srcHint(gameDirStr + path); std::ofstream dstHint(fallbackPath); @@ -606,6 +629,12 @@ RB_METHOD(wallpaperReset){ Debug() << "bliat ono slomalos"; } } + } else if(desktop == "dwm"){ + std::string cmd = originalFehbgExists ? originalFehbgCmd : "xsetroot -solid black"; + int status = std::system(cmd.c_str()); + if (status != 0) { + Debug() << "bliat ono slomalos"; + } } else { if (remove(fallbackPath.c_str()) != 0) { #ifdef DEBUG diff --git a/src/oneshot.cpp b/src/oneshot.cpp index 3558c78..409e98e 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -293,6 +293,8 @@ Oneshot::Oneshot(RGSSThreadData &threadData) : threadData(threadData){ desktopEnv = "budgie"; }else if (desktop.find("pantheon") != std::string::npos){ desktopEnv = "pantheon"; + }else if (desktop.find("dwm") != std::string::npos){ + desktopEnv = "dwm"; } }