core-agent-linux/qubes-rpc/qubes.GetImageRGBA

40 lines
1.0 KiB
Plaintext
Raw Normal View History

2014-01-30 16:30:17 +01:00
set -e
read filename
if [[ "${filename}" = xdgicon:* ]]; then
# get biggest icon from hicolor theme
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}" ]]
2014-01-30 16:30:17 +01:00
filename="${candidate}"
elif [[ "${filename}" = "-" ]] || [[ "${filename}" = *":-" ]]; then
tmpfile="$(mktemp /tmp/qimg-XXXXXXXX)"
cat > "${tmpfile}"
if [[ "$filename" = *":-" ]]; then
tmpfile="${filename%:*}:${tmpfile}"
fi
filename="${tmpfile}"
elif ! [[ -r "${filename}" ]]; then
exit 1
fi
# 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'
2014-01-30 16:30:17 +01:00
convert -depth 8 "$filename" rgba:-
[[ -n "${tmpfile}" ]] && rm -f ${tmpfile} || true
# vim: ft=sh ts=4 sw=4 et