https://github.com/cuarzosoftware/xdgkit
XDG Utilities for C++
https://github.com/cuarzosoftware/xdgkit
icons linux utilities xdg
Last synced: about 2 months ago
JSON representation
XDG Utilities for C++
- Host: GitHub
- URL: https://github.com/cuarzosoftware/xdgkit
- Owner: CuarzoSoftware
- License: lgpl-2.1
- Created: 2025-03-15T03:16:46.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-23T01:01:10.000Z (about 1 year ago)
- Last Synced: 2025-03-23T01:19:35.174Z (about 1 year ago)
- Topics: icons, linux, utilities, xdg
- Language: CSS
- Homepage:
- Size: 271 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# XDGKit
XDGKit is a C++ library providing utilities for working with XDG standards.
### Features
- **Icon Themes**: Tools for searching icons, adhering to the [XDG Icon Theme Specification v0.13](https://specifications.freedesktop.org/icon-theme-spec/latest/#overview).
> This library does not load icons into memory. Instead, it provides fast lookups for icon metadata, including paths, extensions, sizes, and other relevant details.
## Links
- [đ C++ API Documentation](https://cuarzosoftware.github.io/XDGKit/annotated.html)
- [đšī¸ Examples](https://cuarzosoftware.github.io/XDGKit/examples_page.html)
- [đĻ Downloads](https://cuarzosoftware.github.io/XDGKit/downloads_page.html)
- [âī¸ Environment](https://cuarzosoftware.github.io/XDGKit/environment_page.html)
- [đŦ Contact](https://cuarzosoftware.github.io/XDGKit/contact_page.html)
### Example
```cpp
#include
#include
using namespace CZ;
int main()
{
XDGKit::Options options;
// Load themes from cache when possible
options.useIconThemesCache = true;
// Automatically reload themes if a cache update is detected
options.autoReloadCache = true;
// Create an instance of XDGKit.
auto kit = XDGKit::Make(options);
// Search for an icon
const XDGIcon *firefox =
kit->iconThemeManager().findIcon(
"firefox", // Icon to search for
512, // Desired icon size (unscaled)
2, // Scale factor
XDGIcon::PNG | XDGIcon::SVG | XDGIcon::XMP, // File extensions to consider
{ "Adwaita", "" } // Theme names to search in order, "" as wildcard for all themes
);
// Check if the icon was found
if (firefox)
{
std::cout
<< "Theme: " << firefox->directory().theme().name() << "\n"
<< "Icon: " << firefox->name() << "\n"
<< "Size: " << firefox->directory().size() << "\n"
<< "Scale: " << firefox->directory().scale() << "\n";
if (firefox->extensions() & XDGIcon::PNG)
std::cout << "PNG Path: " << firefox->getPath(XDGIcon::PNG) << "\n";
if (firefox->extensions() & XDGIcon::SVG)
std::cout << "SVG Path: " << firefox->getPath(XDGIcon::SVG) << "\n";
if (firefox->extensions() & XDGIcon::XMP)
std::cout << "XMP Path: " << firefox->getPath(XDGIcon::XMP) << "\n";
return 0;
}
else
{
std::cout << "Could not find an icon named 'firefox'." << "\n";
return 1;
}
}
```