#!/bin/bash

d="$@"
ttl=$"Archive File/Folder"; icn="engrampa"
attr="--fixed --title=$ttl --window-icon=$icn --borders=20 --button=OK --text="
[ -z "$d" ] && yad $attr$"No file or folder specified!&#10;" && exit 2
[ ! -e "$d" ] && yad $attr$"&#9;'$d' not found!&#9;&#9;&#10;" && exit 1
arch_list="7z ar cbz ear epub exe jar odp ods odt otp ots ott tar tar.7z tar.bz2 tar.gz tar.lz tar.lzma tar.lzo tar.xz war zip"
t=`yad $attr$"&#9;&#9;Archive Type?&#9;&#9;" --height=670 --list --no-headers --column="Type" ${arch_list[@]}`
[ -z "$t" ] && exit
[ -d "$d" ] && to_compress="$d/*" || to_compress="$d"
engrampa $to_compress -a "$d.${t::-1}"
