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

feat(icons): search for icon themes in $xdg_data_dirs, $xdg_data_home, and ~/.icons#28
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

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