#!/bin/bash
# Send-To
##########################################################################
#                        Nautilus "Send to" Script                       #
##########################################################################
#                                                                        #
# Created by Mattia Galati (Adaron)                                      #
# first improvement and translation by Christopher Bratusek (Chrispy)    #
#                                                                        #
##########################################################################
# Language Settings ---------------------------------------------------- #
destination='Choose Destination'
title_destination='Send files to:'

copy='Copying'
title_copy='Please wait...'

success='Files successfully copied'
title_success='Success'

errors='Something went wrong'
title_errors='Error'

no_writable='Destination is either not existant or writable'
title_no_writable='Error'
# End of language settings ----------------------------------------------#
##########################################################################

devices=`ls -m /media/`
vv=${devices//cdrom?, /}
vd=${vv//cdrom, /}
options=${vd//, / FALSE /media/}
destinazione=`zenity --list --title "$title_destination" --text "$destination" --radiolist --column " " --column "Device" FALSE /media/$options`
 
if [[ -w $destinazione ]]; then
	cp $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS $destinazione | zenity --progress --pulsate --auto-close --title="$title_copy" --text="$copy"
	if (( $? == 0 )); then
		zenity --info --text="$success" --title "$title_success";
	else	zenity --info --text="$errors" --title "$title_errors";
	fi
else	zenity --info --text="$no_writable" --title "$title_no_writable";
fi
