Finds paths to icon files using libsfdo. Libsfdo is currently an

optional compile time dependency. This means the former code paths are
all retained and new ones are wrapped in #if HAVE_LIBSFDO. Behavior
should be identical now between the two code paths. Later commits will
add the handling of icons specified as absolute paths which both former
swaybar code and libsfdo have thus far avoided.
This commit is contained in:
myrslint 2025-04-29 17:37:58 +00:00
parent 3a21b8c6f1
commit aeeb99c5a3
14 changed files with 220 additions and 93 deletions

View file

@ -70,6 +70,14 @@ void free_bar_config(struct bar_config *bar) {
free(bar->colors.binding_mode_border);
free(bar->colors.binding_mode_bg);
free(bar->colors.binding_mode_text);
// this is to cover the case where tray support is not compiled in
// but we have libsfdo support which implies at least a default
// icon_theme string was allocated
#if HAVE_LIBSFDO && !HAVE_TRAY
free(bar->icone_theme);
#endif
#if HAVE_TRAY
list_free_items_and_destroy(bar->tray_outputs);
free(bar->icon_theme);
@ -170,6 +178,13 @@ struct bar_config *default_bar_config(void) {
bar->colors.binding_mode_bg = NULL;
bar->colors.binding_mode_text = NULL;
// we need some default when we initialize sfdo
#if HAVE_LIBSFDO
if (!(bar->icon_theme = strdup("Hicolor"))) {
goto cleanup;
}
#endif
#if HAVE_TRAY
bar->tray_padding = 2;
wl_list_init(&bar->tray_bindings);