Skip to content

feat(icons): search for icon themes in $xdg_data_dirs, $xdg_data_home, and ~/.icons - #28

Open
ddlees wants to merge 2 commits into
hyprwm:mainfrom
ddlees:main
Open

ddlees wants to merge 2 commits into
hyprwm:mainfrom
ddlees:main

Conversation

@ddlees

@ddlees ddlees commented Dec 8, 2025

Copy link
Copy Markdown

This changeset replaces the statically declared icon theme paths with a list built by inspecting the XDG Data directories, XDG_DATA_DIRS and XDG_DATA_HOME, for icons and defaulting to /usr/local/share/icons and /usr/share/icons if the relevant XDG environment variables are undeclared. It will also search for icons in the non-XDG compliant ~/.icons directory to preserve existing function.

The motivation for this change is to allow hyprtoolkit to search for icon themes in non-FHS compliant distributions (e.g. NixOS) more easily. For example, NixOS does not use /usr/share or /usr/local/share directories. Instead, it sets XDG_DATA_DIRS to include /run/current-system/sw/share. I wrote this so I didn't have to wrap the existing nix derivation in a buildFHSEnv or author a patch.

  • Built and tested locally
  • Please forgive my C++. I am very rusty 🙇

Comment thread src/system/Icons.cpp
#include <filesystem>
#include <fstream>

#include <glib.h>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will genuinely ban you from all hypr repos if you include glib in my code again

Comment thread .gitignore
#cmake-build-*

build/
result

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this for?

Comment thread src/system/Icons.cpp
}

// system icons (e.g. /usr/local/share/icons, /usr/share/icons)
const gchar* const* systemDataDirs = g_get_system_data_dirs();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these can be trivially hardcoded as static / constexpr arrays of path suffixes, we do that everywhere else.

@UncleJ4ck

Copy link
Copy Markdown
Contributor

this is the right shape for #33. it's been sitting since 2025-12-08 with conflicts after the recent ConfigManager refactors. @ddlees if you don't have cycles to rebase, happy to push a refresh onto a new branch and credit you as co-author

@UncleJ4ck

UncleJ4ck commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

heads up on where this stands against current main: the $XDG_DATA_DIRS / $XDG_DATA_HOME discovery this PR adds is already there now, getXDGIconThemeDirsFromEnv() in src/system/Icons.cpp walks both. so the only part not covered on main is the non-XDG ~/.icons fallback you add here.

the actual missing-icons bug (a base dir whose theme folder has no index.theme getting skipped, so chromium PWA icons under hicolor never resolve) is #125, which i put up a fix for in #157. up to you whether the ~/.icons bit is still worth landing on its own.

@UncleJ4ck

Copy link
Copy Markdown
Contributor

@ddlees resolved the conflicts against current main here: https://github.com/UncleJ4ck/hyprtoolkit/tree/rescue-28-icons

after the xdg rework only the ~/.icons part was left, so that's the whole diff now: it puts ~/.icons first in the base dirs, like the icon theme spec does. builds and passes on main. merge it into your branch if you want to keep this going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants