# HG changeset patch # User Aleksej Bobylev # Date 1429880654 -10800 # Node ID d749c4f90a067dbc150a5cfbc7d9072529bd4c93 # Parent c389814e4f9a2a4e13935860e2fbd8694d1bb556 pkgs.cgi: allow predefined package icons; tiny improvements. diff -r c389814e4f9a -r d749c4f90a06 tazpanel/pkgs.cgi --- a/tazpanel/pkgs.cgi Sat Apr 18 16:25:03 2015 +0300 +++ b/tazpanel/pkgs.cgi Fri Apr 24 16:04:14 2015 +0300 @@ -94,14 +94,20 @@ echo -n "$pkg" exit 0 ;; + *\ app_img\ * ) # Show application image pkg=$(GET app_img) + if [ -f "$PKGS_DB/packages.icons" ]; then + predefined_icon="$(awk -F$'\t' -vpkg="$pkg" '{if ($1 == pkg) print $2}' $PKGS_DB/packages.icons)" + fi + predefined_icon="${predefined_icon:-package-x-generic}.png" + current_user="$(who | cut -d' ' -f1)" if [ -n "$current_user" ]; then current_user_home="$(awk -F: -vu=$current_user '{if($1==u) print $6}' /etc/passwd)" current_icon_theme="/usr/share/icons/$(grep gtk-icon-theme-name $current_user_home/.gtkrc-2.0 | cut -d'"' -f2)" - default_pkg_icon="$(find -L $current_icon_theme -type f -path '*48*' -name 'package-x-generic.png' | head -n1)" + default_pkg_icon="$(find -L $current_icon_theme -type f -path '*48*' -name $predefined_icon | head -n1)" pkg_icon="$(find -L $current_icon_theme -type f -path '*48*' -name "$pkg.png" | head -n1)" if [ -z "$pkg_icon" ]; then pkg_icon="$(find -L /usr/share/pixmaps -type f -name "$pkg.png" | head -n1)" @@ -110,10 +116,11 @@ header "Content-Type: image/png" cat "${pkg_icon:-$default_pkg_icon}" else - default_pkg_icon="$(find -L /usr/share/icons -type f -name 'package-x-generic.png' | sort | tail -n1)" + default_pkg_icon="$(find -L /usr/share/icons -type f -name $predefined_icon | sort | tail -n1)" fi exit 0 ;; + *\ show_receipt\ * ) # Show package receipt pkg=$(GET show_receipt) @@ -307,7 +314,7 @@ setCookie(name); } -
+