#!/bin/bash
#########################################################
#							#
# This are NScripts v3.4				#
#							#
# Licensed under the GNU GENERAL PUBLIC LICENSE 3	#
#							#
# Copyright 2007 - 2008 Christopher Bratusek		#
#							#
#########################################################

for i in $NAUTILUS_SCRIPT_SELECTED_URIS; do echo $i >> ~/.gnome2/temp_whichpkg_list; done

for file in $(cat ~/.gnome2/temp_whichpkg_list); do

realfile=$(echo $file | sed -e 's/file:\/\///g' -e 's/\%20/\ /g')

pkg=$(grep -w $realfile /var/lib/dpkg/info/*.list | sed -e 's/\.list.*//g' -e 's/.*\/info\///g')

echo -en "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n" >> /tmp/whichpkg.txt
echo "$realfile belongs to the $pkg package." >> /tmp/whichpkg.txt;

done

zenity --text-info --title "Result" --width=640 --height=480 --filename=/tmp/whichpkg.txt

rm -f ~/.gnome2/temp_whichpkg_list
rm -f /tmp/whichpkg.txt

