View Single Post
Posts: 299 | Thanked: 557 times | Joined on Aug 2012
#4557
Originally Posted by Schturman View Post
I found way to see the progress bar + %, it work perfectly with "curl" instead wget... But it work perfectly only in landscape mode, in portrait mode instead one line progress bar you will see something like 15 lines with progress bar
That mean we need somehow to short this bar, but how, I don't know
It is not working because $COLUMNS for curl can't be initialised/accessed from your script unless you had tput for example to get the columns. Workarounds involve unbuffered use of grep and sed.

Note: Harmattan dev repository is down for me atm but I mirrored all ~ 15 gb of packages so I figured for the demo I would just upload those two needed packages to my dropbox account.
I put together some script below. Before you have to install newer version of grep and sed which support unbuffered option.

To do this, open terminal and type (only needed once):
Code:
devel-su
cd /home/user/MyDocs/Downloads/
wget https://www.dropbox.com/s/83k1xf63hg3pzzt/grep_2.6.3-3%2Bmaemo1%2B0m6_armel.deb?dl=1
dpkg -x grep_2.6.3-3+maemo1+0m6_armel.deb /opt/extrautils
wget https://www.dropbox.com/s/hsn5jggyx5mrioq/sed_4.2.1-7%2Bmaemo1%2B0m6_armel.deb?dl=1
dpkg -x sed_4.2.1-7+maemo1+0m6_armel.deb /opt/extrautils

Download script (feel free to modify):
Code:
#!/bin/sh
# little downloader for Schturman's awesome N9 QuickTweak app

download()
{
    local url=$1
    echo -n "    "
    wget --progress=dot $url 2>&1 | /opt/extrautils/bin/grep --line-buffered "%" | \
        /opt/extrautils/bin/sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}'
    echo -ne "\b\b\b\b"
    echo " DONE"
}

file="http://dl.dropbox.com/u/17706605/n9-qtweakall_9.4_armel.deb"
echo -n "Downloading stuff:"
download "$file"
Output looks like:
Code:
~/MyDocs/Downloads $ sh test.sh 
Downloading stuff: 59%

PS: thank you so much by the way for you app - it is great and I really do appreciate it!

Last edited by brkn; 2012-11-08 at 15:48. Reason: added my humble thanks
 

The Following 3 Users Say Thank You to brkn For This Useful Post: