[wiki] [sites] wiki updated

From: <hg_AT_suckless.org>
Date: Wed, 22 Dec 2010 17:04:39 +0000 (UTC)

changeset: 665:938fa466c102
tag: tip
user: Peter John Hartman <peterjohnhartman_AT_gmail.com>
date: Wed Dec 22 12:04:49 2010 -0500
files: surf.suckless.org/patches/smartdownloads.md
description:
Add smartdownloads (a small script to handle downloads in surf)


diff -r 940b31f005f1 -r 938fa466c102 surf.suckless.org/patches/smartdownloads.md
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/surf.suckless.org/patches/smartdownloads.md Wed Dec 22 12:04:49 2010 -0500
_AT_@ -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/)>
Received on Wed Dec 22 2010 - 18:04:39 CET

This archive was generated by hypermail 2.3.0 : Thu Sep 13 2012 - 19:31:34 CEST