@@ -62,6 +62,7 @@ bool CConfigManager::init() {
6262 m_config.addSpecialCategory (" wallpaper" , Hyprlang::SSpecialCategoryOptions{.key = " monitor" });
6363 m_config.addSpecialConfigValue (" wallpaper" , " monitor" , Hyprlang::STRING {" " });
6464 m_config.addSpecialConfigValue (" wallpaper" , " path" , Hyprlang::STRING {" " });
65+ m_config.addSpecialConfigValue (" wallpaper" , " paths" , Hyprlang::STRING {" " });
6566 m_config.addSpecialConfigValue (" wallpaper" , " fit_mode" , Hyprlang::STRING {" cover" });
6667 m_config.addSpecialConfigValue (" wallpaper" , " timeout" , Hyprlang::INT {0 });
6768 m_config.addSpecialConfigValue (" wallpaper" , " order" , Hyprlang::STRING {" default" });
@@ -166,20 +167,47 @@ static std::expected<std::vector<std::string>, std::string> getFullPath(const st
166167 return result;
167168}
168169
170+ static std::expected<std::vector<std::string>, std::string> getFullPaths (const std::string& sv, const bool recursive) {
171+ std::vector<std::string> result;
172+ size_t pos = 0 ;
173+
174+ while (pos < sv.size ()) {
175+ const auto next = sv.find (' ,' , pos);
176+ const auto path = Hyprutils::String::trim (std::string_view{sv}.substr (pos, next == std::string::npos ? sv.size () - pos : next - pos));
177+
178+ if (path.empty ())
179+ return std::unexpected (" empty path in paths" );
180+
181+ const auto RESOLVED_PATH = getFullPath (std::string{path}, recursive);
182+ if (!RESOLVED_PATH )
183+ return std::unexpected (RESOLVED_PATH .error ());
184+
185+ result.append_range (RESOLVED_PATH .value ());
186+
187+ if (next == std::string::npos)
188+ break ;
189+
190+ pos = next + 1 ;
191+ }
192+
193+ return result;
194+ }
195+
169196std::vector<CConfigManager::SSetting> CConfigManager::getSettings () {
170197 std::vector<CConfigManager::SSetting> result;
171198
172199 auto keys = m_config.listKeysForSpecialCategory (" wallpaper" );
173200 result.reserve (keys.size ());
174201
175202 for (auto & key : keys) {
176- std::string monitor, fitMode, path, order;
203+ std::string monitor, fitMode, path, paths, order;
177204 int timeout, recursive;
178205
179206 try {
180207 monitor = std::any_cast<Hyprlang::STRING >(m_config.getSpecialConfigValue (" wallpaper" , " monitor" , key.c_str ()));
181208 fitMode = std::any_cast<Hyprlang::STRING >(m_config.getSpecialConfigValue (" wallpaper" , " fit_mode" , key.c_str ()));
182209 path = std::any_cast<Hyprlang::STRING >(m_config.getSpecialConfigValue (" wallpaper" , " path" , key.c_str ()));
210+ paths = std::any_cast<Hyprlang::STRING >(m_config.getSpecialConfigValue (" wallpaper" , " paths" , key.c_str ()));
183211 timeout = std::any_cast<Hyprlang::INT >(m_config.getSpecialConfigValue (" wallpaper" , " timeout" , key.c_str ()));
184212 order = std::any_cast<Hyprlang::STRING >(m_config.getSpecialConfigValue (" wallpaper" , " order" , key.c_str ()));
185213 recursive = std::any_cast<Hyprlang::INT >(m_config.getSpecialConfigValue (" wallpaper" , " recursive" , key.c_str ()));
@@ -188,19 +216,26 @@ std::vector<CConfigManager::SSetting> CConfigManager::getSettings() {
188216 continue ;
189217 }
190218
191- const auto RESOLVE_PATH = getFullPath (path, recursive != 0 );
219+ if (!path.empty () && !paths.empty ()) {
220+ g_logger->log (LOG_ERR , " Wallpaper {} has both path and paths set" , key);
221+ continue ;
222+ }
223+
224+ const bool USING_PATHS = !paths.empty ();
225+ const auto & PATHS_TO_RESOLVE = USING_PATHS ? paths : path;
226+ const auto RESOLVE_PATHS = USING_PATHS ? getFullPaths (paths, recursive != 0 ) : getFullPath (path, recursive != 0 );
192227
193- if (!RESOLVE_PATH ) {
194- g_logger->log (LOG_ERR , " Failed to resolve path {}: {}" , path, RESOLVE_PATH .error ());
228+ if (!RESOLVE_PATHS ) {
229+ g_logger->log (LOG_ERR , " Failed to resolve path {}: {}" , PATHS_TO_RESOLVE , RESOLVE_PATHS .error ());
195230 continue ;
196231 }
197232
198- if (RESOLVE_PATH .value ().empty ()) {
199- g_logger->log (LOG_ERR , " Provided path(s) '{}' does not contain a valid image" , path );
233+ if (RESOLVE_PATHS .value ().empty ()) {
234+ g_logger->log (LOG_ERR , " Provided path(s) '{}' does not contain a valid image" , PATHS_TO_RESOLVE );
200235 continue ;
201236 }
202237
203- auto resolvedPaths = RESOLVE_PATH .value ();
238+ auto resolvedPaths = RESOLVE_PATHS .value ();
204239
205240 if (resolvedPaths.size () > 1 ) {
206241 if (order != " default" && order != " random" && order != " random-shuffle" ) {
@@ -213,6 +248,9 @@ std::vector<CConfigManager::SSetting> CConfigManager::getSettings() {
213248 std::mt19937 g (rd ());
214249 std::shuffle (resolvedPaths.begin (), resolvedPaths.end (), g);
215250 }
251+
252+ if (USING_PATHS )
253+ resolvedPaths.resize (1 );
216254 }
217255
218256 result.emplace_back (SSetting{.monitor = std::move (monitor), .fitMode = std::move (fitMode), .paths = std::move (resolvedPaths), .order = std::move (order), .timeout = timeout});
0 commit comments