Skip to content

fix(cli): resolve bundled icons at runtime so icons setup works in release builds - #351

Open
angelodibella wants to merge 1 commit into
wayle-rs:masterfrom
angelodibella:fix/icons-setup-resources-path
Open

fix(cli): resolve bundled icons at runtime so icons setup works in release builds#351
angelodibella wants to merge 1 commit into
wayle-rs:masterfrom
angelodibella:fix/icons-setup-resources-path

Conversation

@angelodibella

Copy link
Copy Markdown
Contributor

Problem

wayle icons setup is broken in every packaged build. It locates the bundled icons with a compile-time path (env!("CARGO_MANIFEST_DIR")/../resources/...), which in CI-built release binaries bakes in the runner's workspace:

$ wayle icons setup
Error: Resources directory not found: /__w/wayle/wayle/wayle/../resources/icons/hicolor/scalable/actions

This fails even though the release archive ships the icons right next to the binary, and it means packaged installs (release tarball, AUR wayle-bin) have no way to install or refresh the bundled set.

The practical fallout is worse than a failed command: users who set up icons under an older version and then upgraded across the grappa v1 → v2 icon format change are left with stale stroke-based v1 SVGs on disk, which a v2-era shell renders as filled-in silhouettes (bluetooth rune with its counters filled, night-light reduced to a dot) — with no supported way to fix it.

Fix

Resolve the resources directory at runtime, first existing candidate wins:

  1. <exe_dir>/icons/hicolor/scalable/actions — extracted release-archive layout
  2. /usr/share/wayle/… and /usr/local/share/wayle/… — distro packages that install the shipped icons/ directory
  3. the CARGO_MANIFEST_DIR path — development builds (cargo run from a checkout), unchanged behavior

On no match, the error now lists every searched location instead of one baked-in path.

Testing

  • cargo check / cargo clippy -p wayle clean, cargo fmt applied
  • From a source checkout (candidate 3): installs all 361 bundled icons (verified against a sandboxed XDG_DATA_HOME)
  • Simulated release layout — binary copied beside an icons/ tree (candidate 1): resolves exe-relative and installs
  • Real-world validation: manually applying the equivalent copy on an AUR wayle-bin 0.7.0 install fixed the mangled-icon rendering described above

Note for packagers

With candidate 2 in place, distro packages can simply install the release archive's icons/ directory to /usr/share/wayle/ and wayle icons setup will find it (the AUR wayle-bin PKGBUILD currently drops the icons/ directory entirely — I'll flag that to its maintainer separately).

…release builds

`icons setup` located the bundled icons with a compile-time path
(`env!("CARGO_MANIFEST_DIR")/../resources/...`). In CI-built release
binaries that bakes in the build workspace, so every packaged install
(release tarball, AUR wayle-bin) fails with:

    Error: Resources directory not found: /__w/wayle/wayle/wayle/../resources/icons/hicolor/scalable/actions

even though the release archive ships the icons right next to the
binary. With setup broken there is no way to refresh stale icons, which
bites hard across the grappa v1 -> v2 icon format change: v1 icons left
on disk render as filled-in silhouettes under a v2-era shell.

Resolve the resources directory at runtime instead, first match wins:

1. <exe_dir>/icons/... - extracted release archive layout
2. /usr/share/wayle and /usr/local/share/wayle - distro packages that
   install the shipped icons/ directory
3. the CARGO_MANIFEST_DIR path - development builds (cargo run)

The error message now lists every searched location.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant