A C++17 library that allows you to grab an applications icon on linux
set(iconpp_tests OFF)
If set to
ON
, iconpp will build tests.
- FetchContent
include(FetchContent) FetchContent_Declare(iconpp GIT_REPOSITORY "https://github.com/Soundux/iconpp") FetchContent_MakeAvailable(iconpp) target_link_libraries(<YourLibrary> iconpp)
- Git Submodule
git submodule add "https://github.com/Soundux/iconpp"
# Somewhere in your CMakeLists.txt add_subdirectory("<path_to_iconpp>") target_link_libraries(<YourLibrary> iconpp)
#include <iconpp.hpp>
int main()
{
auto by_pid = iconpp::icon::get(0);
// Or by name: auto by_name = iconpp::icon::get("System Monitor");
if (by_pid)
{
by_pid->save("by_pid.png");
auto raw_image = by_pid->get_raw();
auto base64_img = by_pid->get_base64();
}
return 0;
}
This library does not link its required libraries at compile time. Instead the dependencies are loaded at runtime.
This is done to ensure that the library will compile everywhere but only grab icons on systems that support it - In order to make the library an optional dependency that will not break builds.
The following distributions have been confirmed working with the listed dependencies.
Distribution | Dependencies |
---|---|
Ubuntu | libwnck-3-0 libglib2.0-0 libgdk-pixbuf2.0-0 |
Arch Linux | libwnck3 gdk-pixbuf2 glib2 |