From 27632a0b3bc32af6a77781c05f53d5ceb46044d8 Mon Sep 17 00:00:00 2001 From: Wojciech Zygmunt Porczyk Date: Tue, 4 Feb 2014 00:22:26 +0100 Subject: [PATCH] qubes.GetImageRGBA: bugfixes - when icon is not found in hicolor theme, search for in in other themes - added -follow to find --- qubes-rpc/qubes.GetImageRGBA | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/qubes-rpc/qubes.GetImageRGBA b/qubes-rpc/qubes.GetImageRGBA index 5b3d809..e032486 100644 --- a/qubes-rpc/qubes.GetImageRGBA +++ b/qubes-rpc/qubes.GetImageRGBA @@ -3,12 +3,18 @@ read filename if [[ "${filename}" = xdgicon:* ]]; then # get biggest icon from hicolor theme - candidate=$(find /usr/share/icons/hicolor -type f -name "${filename#*:}.png" | xargs ls --sort=size | head -1) - if [[ ! "$(basename "${candidate}")" = "${filename#*:}.png" ]]; then - # file not found, ls returned garbage - exit 1 - fi + filename="${filename#*:}.png" + candidate= + for dir in /usr/share/icons/{hicolor/,}; do + candidate=$(find -L "${dir}" -type f -name "${filename}") + if [[ -n "${candidate}" ]]; then + candidate=$(echo "${candidate}" | xargs ls --sort=size | head -1) + break + fi + done + + [[ -n "${candidate}" ]] filename="${candidate}" elif [[ "${filename}" = "-" ]] || [[ "${filename}" = *":-" ]]; then @@ -23,7 +29,9 @@ elif ! [[ -r "${filename}" ]]; then exit 1 fi -identify -format '%w %h' "$filename" +# identify in F18 (6.7) adds implicit '\n' to format, +# whereas identify in F20 (6.8) does not +identify -format '%w %h\n' "$filename" | sed -e '/^$/d' convert -depth 8 "$filename" rgba:- [[ -n "${tmpfile}" ]] && rm -f ${tmpfile} || true