aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/tray/icon.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/tray/icon.c')
-rw-r--r--swaybar/tray/icon.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/swaybar/tray/icon.c b/swaybar/tray/icon.c
index bf2736c2..c7ce20b4 100644
--- a/swaybar/tray/icon.c
+++ b/swaybar/tray/icon.c
@@ -301,6 +301,43 @@ static list_t *load_themes_in_dir(char *basedir) {
301 return themes; 301 return themes;
302} 302}
303 303
304static void log_loaded_themes(list_t *themes) {
305 if (themes->length == 0) {
306 sway_log(SWAY_INFO, "Warning: no icon themes loaded");
307 return;
308 }
309
310 const char *sep = ", ";
311 size_t sep_len = strlen(sep);
312
313 size_t len = 1 - sep_len;
314 for (int i = 0; i < themes->length; ++i) {
315 struct icon_theme *theme = themes->items[i];
316 len += strlen(theme->name) + sep_len;
317 }
318
319 char *str = malloc(len);
320 if (!str) {
321 return;
322 }
323 char *p = str;
324 for (int i = 0; i < themes->length; ++i) {
325 if (i > 0) {
326 memcpy(p, sep, sep_len);
327 p += sep_len;
328 }
329
330 struct icon_theme *theme = themes->items[i];
331 size_t name_len = strlen(theme->name);
332 memcpy(p, theme->name, name_len);
333 p += name_len;
334 }
335 *p = '\0';
336
337 sway_log(SWAY_DEBUG, "Loaded icon themes: %s", str);
338 free(str);
339}
340
304void init_themes(list_t **themes, list_t **basedirs) { 341void init_themes(list_t **themes, list_t **basedirs) {
305 *basedirs = get_basedirs(); 342 *basedirs = get_basedirs();
306 343
@@ -311,15 +348,7 @@ void init_themes(list_t **themes, list_t **basedirs) {
311 list_free(dir_themes); 348 list_free(dir_themes);
312 } 349 }
313 350
314 list_t *theme_names = create_list(); 351 log_loaded_themes(*themes);
315 for (int i = 0; i < (*themes)->length; ++i) {
316 struct icon_theme *theme = (*themes)->items[i];
317 list_add(theme_names, theme->name);
318 }
319 char *theme_list = join_list(theme_names, ", ");
320 sway_log(SWAY_DEBUG, "Loaded themes: %s", theme_list);
321 free(theme_list);
322 list_free(theme_names);
323} 352}
324 353
325void finish_themes(list_t *themes, list_t *basedirs) { 354void finish_themes(list_t *themes, list_t *basedirs) {