@@ -63,6 +63,7 @@ bool CConfigManager::init() {
6363 m_config.addSpecialConfigValue (" wallpaper" , " path" , Hyprlang::STRING {" " });
6464 m_config.addSpecialConfigValue (" wallpaper" , " fit_mode" , Hyprlang::STRING {" cover" });
6565 m_config.addSpecialConfigValue (" wallpaper" , " timeout" , Hyprlang::INT {0 });
66+ m_config.addSpecialConfigValue (" wallpaper" , " recursive" , Hyprlang::INT {0 });
6667
6768 m_config.registerHandler (&handleSource, " source" , Hyprlang::SHandlerOptions{});
6869
@@ -118,7 +119,7 @@ static std::expected<std::string, std::string> getPath(const std::string_view& s
118119 return resolvePath (path);
119120}
120121
121- static std::expected<std::vector<std::string>, std::string> getFullPath (const std::string& sv) {
122+ static std::expected<std::vector<std::string>, std::string> getFullPath (const std::string& sv, const bool recursive ) {
122123 if (sv.empty ())
123124 return std::unexpected (" empty path" );
124125
@@ -134,14 +135,27 @@ static std::expected<std::vector<std::string>, std::string> getFullPath(const st
134135 if (!std::filesystem::exists (resolvedPath))
135136 return std::unexpected (std::format (" File '{}' does not exist" , resolvedPath));
136137
137- if (std::filesystem::is_directory (resolvedPath))
138- for (const auto & entry : std::filesystem::directory_iterator (resolvedPath, std::filesystem::directory_options::skip_permission_denied) ) {
138+ if (std::filesystem::is_directory (resolvedPath)) {
139+ auto processEntry = [&result] (const auto & entry) {
139140 if (entry.is_regular_file () && isImage (entry.path ()))
140141 result.push_back (entry.path ());
141-
142- if (result.size () >= maxImagesCount)
143- break ;
142+ };
143+
144+ if (recursive) {
145+ for (const auto & entry :
146+ std::filesystem::recursive_directory_iterator (resolvedPath, std::filesystem::directory_options::skip_permission_denied)) {
147+ processEntry (entry);
148+ if (result.size () >= maxImagesCount)
149+ break ;
150+ }
151+ } else {
152+ for (const auto & entry : std::filesystem::directory_iterator (resolvedPath, std::filesystem::directory_options::skip_permission_denied)) {
153+ processEntry (entry);
154+ if (result.size () >= maxImagesCount)
155+ break ;
156+ }
144157 }
158+ }
145159 else if (isImage (resolvedPath))
146160 result.push_back (resolvedPath);
147161 else
@@ -158,19 +172,20 @@ std::vector<CConfigManager::SSetting> CConfigManager::getSettings() {
158172
159173 for (auto & key : keys) {
160174 std::string monitor, fitMode, path;
161- int timeout;
175+ int timeout, recursive ;
162176
163177 try {
164178 monitor = std::any_cast<Hyprlang::STRING >(m_config.getSpecialConfigValue (" wallpaper" , " monitor" , key.c_str ()));
165179 fitMode = std::any_cast<Hyprlang::STRING >(m_config.getSpecialConfigValue (" wallpaper" , " fit_mode" , key.c_str ()));
166180 path = std::any_cast<Hyprlang::STRING >(m_config.getSpecialConfigValue (" wallpaper" , " path" , key.c_str ()));
167181 timeout = std::any_cast<Hyprlang::INT >(m_config.getSpecialConfigValue (" wallpaper" , " timeout" , key.c_str ()));
182+ recursive = std::any_cast<Hyprlang::INT >(m_config.getSpecialConfigValue (" wallpaper" , " recursive" , key.c_str ()));
168183 } catch (...) {
169184 g_logger->log (LOG_ERR , " Failed parsing wallpaper for key {}" , key);
170185 continue ;
171186 }
172187
173- const auto RESOLVE_PATH = getFullPath (path);
188+ const auto RESOLVE_PATH = getFullPath (path, recursive != 0 );
174189
175190 if (!RESOLVE_PATH ) {
176191 g_logger->log (LOG_ERR , " Failed to resolve path {}: {}" , path, RESOLVE_PATH .error ());
0 commit comments