diff --git a/Makefile b/Makefile index b3a3c5a..f3895dd 100644 --- a/Makefile +++ b/Makefile @@ -180,6 +180,7 @@ install-common: install qubes-rpc/qvm-copy-to-vm.gnome $(DESTDIR)$(LIBDIR)/qubes install qubes-rpc/qvm-move-to-vm.kde $(DESTDIR)$(LIBDIR)/qubes install qubes-rpc/qvm-move-to-vm.gnome $(DESTDIR)$(LIBDIR)/qubes + install qubes-rpc/xdg-icon $(DESTDIR)$(LIBDIR)/qubes install qubes-rpc/{vm-file-editor,qfile-agent,qopen-in-vm} $(DESTDIR)$(LIBDIR)/qubes install qubes-rpc/tar2qfile $(DESTDIR)$(LIBDIR)/qubes # Install qfile-unpacker as SUID - because it will fail to receive files from other vm diff --git a/debian/control b/debian/control index bce4791..92e418a 100644 --- a/debian/control +++ b/debian/control @@ -19,6 +19,7 @@ Depends: initscripts, iptables, iptables-persistent, + librsvg2-bin, libvchan-xen, locales, ncurses-term, diff --git a/qubes-rpc/qubes.GetImageRGBA b/qubes-rpc/qubes.GetImageRGBA index b9eb782..a45fc40 100644 --- a/qubes-rpc/qubes.GetImageRGBA +++ b/qubes-rpc/qubes.GetImageRGBA @@ -1,22 +1,13 @@ set -e read filename +ICON_MAXSIZE=512 + if [ "${filename%%:*}" = xdgicon ]; then - # get biggest icon from hicolor theme - - filename="${filename#*:}.png" - candidate= - for dir in /usr/share/icons/hicolor/ /usr/share/icons/; 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}" + filename="$(/usr/lib/qubes/xdg-icon "${filename#*:}" "$ICON_MAXSIZE")" + forcesize="$ICON_MAXSIZE" + [ -n "${filename}" ] elif [ "${filename}" = "-" ] || [ "${filename##*:}" = "-" ]; then tmpfile="$(mktemp /tmp/qimg-XXXXXXXX)" cat > "${tmpfile}" @@ -29,11 +20,23 @@ 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' -convert -depth 8 "$filename" rgba:- +s="$(identify -format '%w %h %m' "$filename")" +w="$(echo "$s"|cut -d " " -f 1)" +h="$(echo "$s"|cut -d " " -f 2)" +m="$(echo "$s"|cut -d " " -f 3)" +if [ "$m" = SVG ]; then + if [ -n "$forcesize" ]; then + w="$forcesize" + h="$forcesize" + fi + tmpfile2="$(mktemp /tmp/qimg-XXXXXXXX.png)" + rsvg-convert -w "$w" -h "$h" -o "$tmpfile2" "$filename" + filename="$tmpfile2" +fi +echo "$w $h" +convert -depth 8 -size "${w}x${h}" "$filename" rgba:- [ -n "${tmpfile}" ] && rm -f "${tmpfile}" || true +[ -n "${tmpfile2}" ] && rm -f "${tmpfile2}" || true # vim: ft=sh ts=4 sw=4 et diff --git a/qubes-rpc/xdg-icon b/qubes-rpc/xdg-icon new file mode 100755 index 0000000..5a981fa --- /dev/null +++ b/qubes-rpc/xdg-icon @@ -0,0 +1,21 @@ +#!/usr/bin/python +import xdg.IconTheme +import sys +import os + +themes = ['Humanity', 'Adwaita', 'gnome', 'oxygen'] +themes = themes + sorted([d for d in os.listdir("/usr/share/icons") if d not in themes and os.path.isdir("/usr/share/icons/" + d)]) + +if len(sys.argv) < 3: + print "Usage:", sys.argv[0], "ICON SIZE" + sys.exit(1) + +for theme in themes: + icon = xdg.IconTheme.getIconPath(sys.argv[1], theme = theme, size = int(sys.argv[2])) + if icon is not None: + break + +if icon is None: + sys.exit(1) + +print icon diff --git a/rpm_spec/core-vm.spec b/rpm_spec/core-vm.spec index 638c4c0..ad1cebd 100644 --- a/rpm_spec/core-vm.spec +++ b/rpm_spec/core-vm.spec @@ -51,13 +51,14 @@ Requires: qubes-utils Requires: initscripts # for qubes-desktop-run Requires: pygobject3-base -# for qubes-session-autostart +# for qubes-session-autostart, xdg-icon Requires: pyxdg %if %{fedora} >= 20 # gpk-update-viewer required by qubes-manager Requires: gnome-packagekit-updater %endif Requires: ImageMagick +Requires: librsvg2-tools Requires: fakeroot Requires: desktop-notification-daemon Requires: pygtk2 @@ -410,6 +411,7 @@ rm -f %{name}-%{version} /usr/lib/qubes/wrap-in-html-if-url.sh /usr/lib/qubes/iptables-updates-proxy /usr/lib/qubes/close-window +/usr/lib/qubes/xdg-icon /usr/lib/yum-plugins/yum-qubes-hooks.py* /usr/lib64/python2.7/site-packages/qubes/xdg.py* /usr/sbin/qubes-firewall