sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit a226e424dd3b90b81f9b814cd9e6ac3f10db346f
parent ba772db1b18ffa7b4eb162c68a9699c6887237c7
Author: Peter John Hartman <peterjohnhartman@gmail.com>
Date:   Wed, 22 Dec 2010 12:04:49 -0500

Add smartdownloads (a small script to handle downloads in surf)
Diffstat:
Asurf.suckless.org/patches/smartdownloads.md | 37+++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+), 0 deletions(-)

diff --git a/surf.suckless.org/patches/smartdownloads.md b/surf.suckless.org/patches/smartdownloads.md @@ -0,0 +1,37 @@ +SMARTDOWNLOADS +======= + +Description +----------- + +This script makes wget launch the app you want to launch (based on mailcap) when you download it. +There's almost certainly better ways of doing this, but this is an example. Call this in config.h. + + #!/bin/sh + + function parse_download() { + + filename="" + filename=$(grep "Saving to:" /tmp/surf-dl.$$ |\ + cut -d '`' -f2 |\ + sed "s/'//") + echo "NEW FILENAME: $filename" + if [[ $filename == "" ]]; then + filename=$(grep "Server file no newer" /tmp/surf-dl.$$ |\ + cut -d '`' -f2 |\ + sed "s/'.*//") + fi + echo "ALREADY EXISTS FILENAME: $filename" + if [[ $filename != "" ]]; then + run-mailcap $filename + fi + rm -f /tmp/surf-dl.$$ + } + + wget -N --load-cookies ~/.surf/cookies.txt $1 \ + -o /tmp/surf-dl.$$ && parse_download + +Authors +------- + +* Peter John Hartman (wart_) <[http://durandus.trilidun.org/durandus/](http://durandus.trilidun.org/durandus/)>