#!/bin/bash

case $LANG in
	es*)
		TIT="Desmontaje USB"
		MSG1="Ahora puede extraer con seguridad el dispositivo USB"
		MSG2="No se pudo desmontar. No extraiga el dispositivo.\n\n "
		MSG3="El proceso"
		MSG4="está impidiendo el desmontaje."
	;;
	gl*)
		TIT="Desmontaxe USB"
		MSG1="Agora pode extraer o dispositivo USB con seguridade"
		MSG2="Non foi posíbel desmontalo. Non extraia o dispositivo. \n\n"
        MSG3="O proceso"
        MSG4="está a impedir a desmontaxe."


	;;
	ca*)
       TIT="Desmuntatge USB"
       MSG1="Ara pots extreure amb seguretat el dispositiu USB"
       MSG2="No s'ha pogut desmuntar. No treguis el dispositiu. \n\n"
       MSG3="El procés"
       MSG4="està impedint el desmuntaje."

	;;
	*)
		TIT="Umount USB"
		MSG1="Now you can do a secure unplugging of your USB drive"
		MSG2="Impossible to umount. Don't unplug you USB drive. \n\n"
		MSG3="The process"
		MSG4="is preventing the device to be unplugged."

	;;
esac

ICO="drive-harddisk-usb"

sync
pumount "$1"
udisks --detach "$2"

if [ "$?" == "0" ];then
    yad --title "$TIT" --info --text "\n  $MSG1  \n" \
		--image "gtk-apply" --window-icon "$ICO" --button "gtk-ok:0"
else
	PID=`fuser -m "$1"|cut -d " " -f3`
	PROCESO=`cat /proc/$PID/comm`
    yad --title "$TIT" --info --text "  $MSG2  $MSG3 <b>$PROCESO</b> $MSG4\n" \
		--image "gtk-no" --window-icon "$ICO" --button "gtk-ok:0"
fi
