1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| save_dir0=~/Download max_num=20 [ ! -d $save_dir0 ] && mkdir -p $save_dir0
DOWNLOAD() { axel -n $max_num "$1" -o "$2/$3" |while read a;do echo "$a" |grep "<!-- /[D -->" |sed 's/^/[ *//;s/%.*$//;s/^Download.*$/100/' done |zenity --progress --auto-close --text="下载 $true_url 至 $2" --width="350" 2>/dev/null & axel_info=`ps ax |grep "axel.*$1" |awk '{print $1"-"$2}'` axel_tty=`echo $axel_info |sed 's/^.*-//'` axel_pid=`echo $axel_info |sed 's/-.*$//'` while true;do if ! [ "`ps ax |grep "$axel_tty.*zenity"`" ];then [ "`ps -A |grep "$axel_pid"`" ] && kill $axel_pid break fi sleep 1 done & }
UI() { choice=$(zenity --list --title "默认保存目录为:$save_dir0" --text "解析得URL:$true_url" / --column "选项" --column "动作" / A 下载至默认目录 B 选择目录并下载 C 保存链接到剪贴板 2>/dev/null); case $choice in 'A') file_name=`zenity --entry --title="重命名文件" --text="请输入一个文件名(取消则按链接默认命名)" 2>/dev/null` DOWNLOAD $true_url $save_dir0 $file_name file_name="" ;; 'B') save_dir=`zenity --file-selection --directory 2>/dev/null` file_name=`zenity --entry --title="重命名文件" --text="请输入一个文件名(取消则按链接默认命名)" 2>/dev/null` DOWNLOAD $true_url $save_dir $file_name file_name="" ;; 'C') printf "$true_url" |xsel -i -b ;; esac }
DECODE() { str0="`xsel -b`" if [ `echo "$str0" |grep "^thunder"` ] && [ "$str" != "$str0" ];then str="$str0" true_url="`printf "$str" |sed 's/^thunder://////' |base64 -d |sed 's/^AA//;s/ZZ$//'`" [ ! -z "$true_url" ] && UI true_url="" fi }
while true;do DECODE sleep 1 done
|