Skip to content

Instantly share code, notes, and snippets.

@farhaven
Created October 14, 2014 11:48
Show Gist options
  • Save farhaven/f23ad5b535719c661018 to your computer and use it in GitHub Desktop.
Save farhaven/f23ad5b535719c661018 to your computer and use it in GitHub Desktop.
#!/bin/sh
dir=$1 # directory into which to download the file
url=$2 # url of file to download
name=$3 # suggested name of file to download
cookies=$4 # path to cookiejar
agent=$5 # useragent
referer=$6 # referer
embed=$7 # window id to embed st into
xmessage -nearmouse -buttons "Download,Download and Open,Cancel" -default "Download" "Downloading
$url
to
$dir/$name"
action=$?
unset http_proxy
unset https_proxy
if [ "$action" == 103 ]; then
exit
fi
cd "$dir"
st -w $embed -e /bin/sh -c \
"cd '$dir'; echo '$name'; curl -C - -k -L -J -o '$name' --user-agent '$agent' --referer '$referer' -b '$cookies' -c '$cookies' '$url' || read"
echo $action
if [ "$action" == 102 ]; then
mimehandler "$dir/$name"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment