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
2015-02-05 03:14:41 +01:00
if [ "${filename%%:*}" = xdgicon ]; then
2014-01-30 16:30:17 +01:00
# get biggest icon from hicolor theme
filename="${filename#*:}.png"
candidate=
2015-02-05 03:14:41 +01:00
for dir in /usr/share/icons/hicolor/ /usr/share/icons/; do
candidate=$(find -L "${dir}" -type f -name "${filename}")
2015-02-05 03:14:41 +01:00
if [ -n "${candidate}" ]; then
candidate=$(echo "${candidate}" | xargs ls --sort=size | head -1)
break
fi
done
2015-02-05 03:14:41 +01:00
[ -n "${candidate}" ]
2014-01-30 16:30:17 +01:00
filename="${candidate}"
2015-02-05 03:14:41 +01:00
elif [ "${filename}" = "-" ] || [ "${filename##*:}" = "-" ]; then
2014-01-30 16:30:17 +01:00
tmpfile="$(mktemp /tmp/qimg-XXXXXXXX)"
cat > "${tmpfile}"
2015-02-05 03:14:41 +01:00
if [ "${filename##*:}" = "-" ]; then
2014-01-30 16:30:17 +01:00
tmpfile="${filename%:*}:${tmpfile}"
fi
filename="${tmpfile}"
2015-02-05 03:14:41 +01:00
elif ! [ -r "${filename}" ]; then
2014-01-30 16:30:17 +01:00
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:-
2015-02-05 03:14:41 +01:00
[ -n "${tmpfile}" ] && rm -f ${tmpfile} || true
2014-01-30 16:30:17 +01:00
# vim: ft=sh ts=4 sw=4 et