You are not logged in.

#1 2010-09-12 20:05:29

exe
Member
Registered: 2009-11-20
Posts: 3

[Solved] dzen and curl

I have been trying to figure out how to pipe the percent of curl to dzen widget realtime with no luck so far, is having a stat file the only way? i have seen the uzbl wiki scripts but i dont understand all the code,
i have my browser(surf) to handle my downloads via the following script, i just want to add some kind of notification AND status to it, a place where i can see whats going on. any help would be great thanks

the argumment passed to the script is the url
handler.sh

#!/bin/bash
DOWNLOAD_DIR=/home/user/downloads
cd $DOWNLOAD_DIR
curl -# -o `basename $1` "$1"
#do update percent while not done
#do notify finished

Last edited by exe (2010-09-15 14:34:20)

Offline

#2 2010-09-12 21:02:08

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [Solved] dzen and curl

You might be able to do something with expect (see http://en.wikipedia.org/wiki/Expect) but I don't know that app.
Otherwise, the problem is that piping the output means that the receiver it only gets the last update - eg 100%. So you do really need to use a file.

Try this (untested will need a tweak or two):

curl -# -o $TARGET $URL > progress 2>&1 &
PID=$!

while ps -A | grep -q $pid; do
    REM="$(awk '{print $NF}' progress)"
done

And build from there.

You'll need to do something with REM (check-out OSD_CAT for an alternative way of showing progress), and tidy-up the file, etc.

Last edited by skanky (2010-09-12 21:04:13)


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#3 2010-09-13 00:40:47

exe
Member
Registered: 2009-11-20
Posts: 3

Re: [Solved] dzen and curl

thanks i will give it a go and report back big_smile

Offline

#4 2010-09-15 00:29:57

exe
Member
Registered: 2009-11-20
Posts: 3

Re: [Solved] dzen and curl

so yeah tried and looks like the only option is to write a file, i checked a script over at the uzbl wiki and they handle multiple downloads writing to tmp/file.$PID that way you can keep track of multiple wget/curl instances with ps, i have not decided what to use to download my files, i also tried gwget and is nice as you can add urls from the cli directly into the gui by just calling it with the url and it does notify, however it uses gnome deps wich are quite pig (as in heavy), isnt there a gtk alternative to gwget? thanks in advance.

Offline

Board footer

Powered by FluxBB