diff --git a/src/modules/wlr/taskbar.cpp b/src/modules/wlr/taskbar.cpp index 15b927a8..c2acbd9a 100644 --- a/src/modules/wlr/taskbar.cpp +++ b/src/modules/wlr/taskbar.cpp @@ -1,5 +1,7 @@ #include "modules/wlr/taskbar.hpp" +#include "glibmm/error.h" +#include "glibmm/fileutils.h" #include "glibmm/refptr.h" #include "util/format.hpp" @@ -74,6 +76,16 @@ static std::vector search_prefix() return prefixes; } +static Glib::RefPtr load_icon_from_file(std::string icon_path, int size) +{ + try { + auto pb = Gdk::Pixbuf::create_from_file(icon_path, size, size); + return pb; + } catch(...) { + return {}; + } +} + /* Method 1 - get the correct icon name from the desktop file */ static std::string get_from_desktop_app_info(const std::string &app_id) { @@ -172,7 +184,17 @@ static bool image_load_icon(Gtk::Image& image, const Glib::RefPtrload_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); + Glib::RefPtr pixbuf; + + try { + pixbuf = icon_theme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); + } catch(...) { + if (Glib::file_test(icon_name, Glib::FILE_TEST_EXISTS)) + pixbuf = load_icon_from_file(icon_name, size); + else + pixbuf = {}; + } + if (pixbuf) { image.set(pixbuf); found = true;