omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

AppLibrary icon index ignores the active icon theme: first filesystem hit wins, so app icons come from hicolor and change between rescans

Open assada opened this issue 3 months ago • 4 comments

System details

Omarchy 4.0.0-1, Hyprland 0.56.2, quickshell-git 0.3.0.r20.g28771c7-1, Arch Linux, kernel 7.1.8-arch1-3, Intel i5-8350U / UHD 620. /usr/share on btrfs. Icon theme set to Tela-circle (tela-circle-icon-theme-all 2026_07_07-1).

What is wrong?

shell/services/AppLibrary.qml builds its own icon index and consults it before the themed lookup, so the icon theme selected in org.gnome.desktop.interface icon-theme is largely ignored for application icons in the menu/launcher.

The scan (iconIndexScanCommand()) walks every XDG icon directory and takes every */apps/* and */devices/* file:

dirs="$HOME/.icons $HOME/.local/share/icons";
IFS=":"; for d in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}; do dirs="$dirs $d/icons"; done; unset IFS;
for ext in svg png; do
  for base in $dirs; do
    [[ -d $base ]] && find "$base" \( -path "*/apps/*" -o -path "*/devices/*" \) -name "*.$ext" 2>/dev/null;
  done
  find /usr/share/pixmaps -maxdepth 1 -name "*.$ext" 2>/dev/null;
done

indexIconLine() keys purely on the file's basename and keeps the first hit:

if (name.length > 0 && root.pendingIconIndex[name] === undefined)
  root.pendingIconIndex[name] = value

and iconSource() gives that index precedence over Quickshell.iconPath():

var found = root.iconIndex[value]
if (found) return Util.fileUrl(found)
var themed = Quickshell.iconPath(value, true)
if (themed.length > 0) return themed

Nothing in this path knows which icon theme is active. Whichever theme on disk find happens to reach first wins.

Consequence 1 — the selected theme loses to whatever is found first. With icon-theme set to Tela-circle, only 20 of the 67 non-absolute Icon= names across my installed desktop entries resolved into Tela-circle; 42 came from hicolor/breeze/Adwaita, including names Tela-circle does provide:

NAME               IN-THEME INDEX PICKS (first hit wins)
foot               yes      /usr/share/icons/hicolor/scalable/apps/foot.svg
mpv                yes      /usr/share/icons/hicolor/scalable/apps/mpv.svg
btop               yes      /usr/share/icons/hicolor/scalable/apps/btop.svg
kdenlive           yes      /usr/share/icons/hicolor/scalable/apps/kdenlive.svg
libreoffice-calc   yes      /usr/share/icons/hicolor/scalable/apps/libreoffice-calc.svg

Since hicolor holds each application's own upstream icon, the practical effect is that installing an icon theme changes little in the launcher, and which icons do change is arbitrary.

Consequence 2 — the winner is not stable across rescans. find output order is not guaranteed. On btrfs here, five consecutive identical scans produced identical content in five different orders (diff <(sort a) <(sort b) is empty; diff a b is not). So the same name can resolve to a different theme on the next scan. Because refreshIcons() re-runs the scan whenever a consumer opens — and per #6806 it can fire roughly once a second — icons visibly change with no user action. That is how I noticed this: icons flipped between themed and stock while I was doing nothing.

Note that the code comment describes the index as a fallback for icons Qt's themed lookup misses (newly installed apps), but it is currently the primary resolver.

Steps to recreate

# 1. Install any icon theme that overlaps hicolor, e.g.
sudo pacman -S tela-circle-icon-theme
gsettings set org.gnome.desktop.interface icon-theme Tela-circle
omarchy restart shell

# 2. Replay the scan exactly as AppLibrary.qml runs it
scan() {
  local dirs="$HOME/.icons $HOME/.local/share/icons"
  IFS=":"; for d in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}; do dirs="$dirs $d/icons"; done; unset IFS
  for ext in svg png; do
    for base in $dirs; do
      [[ -d $base ]] && find "$base" \( -path "*/apps/*" -o -path "*/devices/*" \) -name "*.$ext" 2>/dev/null
    done
    find /usr/share/pixmaps -maxdepth 1 -name "*.$ext" 2>/dev/null
  done
}
scan > /tmp/s1; scan > /tmp/s2

# 3. The active theme loses to hicolor even though it ships the icon
ls /usr/share/icons/Tela-circle/scalable/apps/foot.svg   # exists
grep -m1 '/foot\.' /tmp/s1                               # -> hicolor/scalable/apps/foot.svg

# 4. Same content, different order on every run
diff <(sort /tmp/s1) <(sort /tmp/s2) | wc -l   # 0
diff /tmp/s1 /tmp/s2 | wc -l                   # non-zero

Then open the Apps menu: icons come from a mix of themes, and change between openings.

Expected

Application icons should come from the icon theme the user selected, and should not change on their own.

Suggested fix

Either restrict the scan to the active theme plus its Inherits chain (then hicolor), or — probably simpler — restore the index to the fallback role its comment describes: try Quickshell.iconPath() first, since it already honours the icon theme, and fall back to the index only for names the themed lookup misses. Sorting each find (find ... | sort) would additionally make the outcome deterministic regardless of filesystem traversal order.

Workaround (verified)

Force the wanted theme to the front of the scan by putting its app/device icons in $HOME/.icons, which the scan reads first:

mkdir -p ~/.icons/tela-priority/scalable/{apps,devices}
find /usr/share/icons/Tela-circle/scalable/apps    -maxdepth 1 -name '*.svg' -exec ln -sf {} ~/.icons/tela-priority/scalable/apps/    \;
find /usr/share/icons/Tela-circle/scalable/devices -maxdepth 1 -name '*.svg' -exec ln -sf {} ~/.icons/tela-priority/scalable/devices/ \;
omarchy restart shell

This raised the count from 20 to 46 of 67, deterministically. Two details matter: the scan's find has no -L, so a symlink to the theme directory is invisible to it and the links must be per-file; and the directory deliberately has no index.theme, so GTK/Qt do not treat it as a theme.

assada avatar Aug 19 '26 22:08 assada

@assada - Yes, I agree. Do you have an open PR for this?

aarishk avatar Aug 20 '26 02:08 aarishk

Still present on current quattro. Reproduced here with icon-theme set to Papirus and a pile of other themes installed under ~/.local/share/icons: of the 150 non-absolute Icon= names across my desktop entries, 2 resolved into Papirus. 67 came from Nordzy-cyan-dark, which isn't selected anywhere. Narrowing it to names Papirus actually ships: 118 of 120 were served from some other theme.

I'd like to take this. One thing worth flagging before I do — the index-before-theme order isn't accidental. app-search-test.sh asserts it ("app library prefers indexed app icons over ambiguous themed icons"), and Quickshell.iconPath returns an image:// URL, so there's no way to look at what context it resolved into and reject an actions/ hit after the fact. So swapping the two lookups would reintroduce the zoom-style collisions that ordering is there to prevent.

What does look wrong is what the index contains: it walks every theme on disk and keeps whatever find reaches first. Scoping the scan to the active theme plus hicolor gets the precedence right without touching the resolution order, keeps the apps/devices context limit that guards the generic names, and leaves Quickshell.iconPath as the fallback for anything further up the inherits chain. It also makes the scan noticeably cheaper.

I'll send that with coverage over the resolution precedence.

VykosMolt avatar Aug 31 '26 16:08 VykosMolt

Same class of problem as reported here, and it survives the scoping rewrite proposed in #10480: iconIndexScanCommand() covers */apps/*, */devices/* and flat /usr/share/pixmaps, but never the flat legacy icon path <datadir>/icons/<name>.svg. Packagers still install there — it is the freedesktop legacy location and GTK's own icon lookup honours it — so the app resolves fine in GTK/Qt dialogs and falls through to application-x-executable in the menu.

Repro on stock Omarchy 4 (quattro, AppLibrary.qml at f4378f0d):

yay -S fladder-bin                     # AUR PKGBUILD installs /usr/share/icons/fladder.svg
ls /usr/share/icons/*.svg              # -> /usr/share/icons/fladder.svg (the only flat icon here)
# open the Apps menu, search "fladder": generic placeholder instead of the app icon

iconSource("fladder") misses the index, then Quickshell.iconPath() looks only inside themed <theme>/<size>/apps trees, so it misses too.

One extra pass alongside the existing pixmaps line covers it:

for base in $dirs; do
  [[ -d $base ]] && find "$base" -maxdepth 1 -name "*.$ext" 2>/dev/null;
done

Placed after the existing */apps/* loop (and after the pixmaps line) it only adds names nothing else provided — it cannot shadow a themed app hit, so the zoom-style ordering that app-search-test.sh guards is untouched. Collision risk is nil on a stock install: that pass yields exactly one path here (/usr/share/icons/fladder.svg; find /usr/share/icons -maxdepth 1 -name '*.png' -o -name '*.svg' | wc -l = 1).

I didn't open a separate PR because #10480 rewrites this function. If @VykosMolt wants it folded in, happy to send it as a patch to that branch; otherwise I can open a two-line PR off quattro.

dadofsambonzuki avatar Sep 15 '26 07:09 dadofsambonzuki

Checked this against current quattro (b83d3df) and the defect is still there: shell/services/AppLibrary.qml scans every installed theme's apps/devices directories in unsorted find order (line 132), keeps the first file for each name (line 146), and consults that index before Quickshell.iconPath() (line 64). Nothing reads the active icon theme, so the selected theme can lose to hicolor or any other installed theme, and the winner can change from one scan to the next.

#9408 is the open fix and already closes this issue. It walks the active theme and its Inherits chain, then hicolor, and sorts each scan, which covers both the wrong theme winning and the order changing between rescans. It was reproduced on a worker as its own item (wrong theme on quattro, active theme with the change, wrong again with the change reverted) and is labelled verified; it is reviewed and tracked there rather than here.

One point from this thread that #9408 does not cover: flat legacy icons at <datadir>/icons/<name>.svg (the fladder-bin case above). Its scan, like quattro's, only looks under a theme's apps/devices directories and /usr/share/pixmaps. That is a separate gap and would need its own change.

Reviewed by Claude Opus 5.5 and, as a second opinion, Codex at medium effort, which reached the same conclusions from the source, including the flat-icon gap; its independence is not guaranteed. This now waits on the maintainer's decision on #9408.

omarchybot avatar Oct 08 '26 11:10 omarchybot