From 453ab0f22cb24e29558e63b703d1fe6546189d73 Mon Sep 17 00:00:00 2001 From: Wojciech Zygmunt Porczyk Date: Thu, 30 Jan 2014 16:30:17 +0100 Subject: [PATCH] qubes.GetImageRGBA for appicons --- Makefile | 1 + qubes-rpc/qubes.GetImageRGBA | 31 +++++++++++++++++++++++++++++++ rpm_spec/core-vm.spec | 2 ++ 3 files changed, 34 insertions(+) create mode 100644 qubes-rpc/qubes.GetImageRGBA diff --git a/Makefile b/Makefile index 553c552..789bb74 100644 --- a/Makefile +++ b/Makefile @@ -138,6 +138,7 @@ install-vm: install -m 0644 qubes-rpc/qubes.WaitForSession $(DESTDIR)/etc/qubes-rpc install -m 0644 qubes-rpc/qubes.DetachPciDevice $(DESTDIR)/etc/qubes-rpc install -m 0644 qubes-rpc/qubes.{Backup,Restore} $(DESTDIR)/etc/qubes-rpc + install -m 0644 qubes-rpc/qubes.GetImageRGBA $(DESTDIR)/etc/qubes-rpc install -d $(DESTDIR)/usr/share/file-manager/actions install -m 0644 qubes-rpc/*-gnome.desktop $(DESTDIR)/usr/share/file-manager/actions diff --git a/qubes-rpc/qubes.GetImageRGBA b/qubes-rpc/qubes.GetImageRGBA new file mode 100644 index 0000000..5b3d809 --- /dev/null +++ b/qubes-rpc/qubes.GetImageRGBA @@ -0,0 +1,31 @@ +set -e +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="${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 -format '%w %h' "$filename" +convert -depth 8 "$filename" rgba:- + +[[ -n "${tmpfile}" ]] && rm -f ${tmpfile} || true + +# vim: ft=sh ts=4 sw=4 et diff --git a/rpm_spec/core-vm.spec b/rpm_spec/core-vm.spec index b68071a..27ff723 100644 --- a/rpm_spec/core-vm.spec +++ b/rpm_spec/core-vm.spec @@ -48,6 +48,7 @@ Requires: net-tools Requires: nautilus-actions Requires: qubes-core-vm-kernel-placeholder Requires: qubes-utils +Requires: ImageMagick Provides: qubes-core-vm Obsoletes: qubes-core-commonvm Obsoletes: qubes-core-appvm @@ -279,6 +280,7 @@ rm -f %{name}-%{version} /etc/qubes-rpc/qubes.DetachPciDevice /etc/qubes-rpc/qubes.Backup /etc/qubes-rpc/qubes.Restore +/etc/qubes-rpc/qubes.GetImageRGBA /etc/sudoers.d/qubes %config(noreplace) /etc/sysconfig/iptables %config(noreplace) /etc/sysconfig/ip6tables