diff --git a/dsv/README b/dsv/README new file mode 100644 index 0000000..1434472 --- /dev/null +++ b/dsv/README @@ -0,0 +1,24 @@ +Setting the PDF viewer +---------------------- + +If the environment variable DSV_VIEWER is set, dsv will launch the +program specified there. + +If DSV_VIEWER is not set but DSV_PDFVIEWER is set, dsv will launch +the program specified in DSV_PDFVIEWER. + +If neither DSV_VIEWER nor DSV_PDFVIEWER are set, dsv will run +xdg-open to launch the viewer. + +xdg-open typically defaults to the "evince" viewer. The default +can be changed from the command line with + +xdg-mime default APPLICATION application/pdf + +where APPLICATION is one of the *.desktop files typically found +in /usr/share/applications/ or /usr/local/share/applications/ + +For example, to make xpdf the default xdg-open (and hence many +other applications) uses, one would run + +xdg-mime default xpdf.desktop application/pdf diff --git a/dsv/dsv b/dsv/dsv index 3fdeb9f..7f6a103 100755 --- a/dsv/dsv +++ b/dsv/dsv @@ -2,8 +2,8 @@ # # dsv - Improved data sheet viewer # -# Written 2010, 2011 by Werner Almesberger -# Copyright 2010, 2011 Werner Almesberger +# Written 2010-2012 by Werner Almesberger +# Copyright 2010-2012 Werner Almesberger # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -67,8 +67,12 @@ flush() # @@@ should handle error else url=${url%`echo x"$inside" | sed 's/./?/g'`} - wget -nv -O "$DSV_DIR/_tmp" "$url" - unzip -p "$DSV_DIR/_tmp" "$inside" >"$DSV_DIR/$ds" || + zip=$nm-`basename "$url"` + if [ ! -r "$DSV_DIR/$zip" ]; then + wget -nv -O "$DSV_DIR/$zip" "$url" + # @@@ should handle error + fi + unzip -p "$DSV_DIR/$zip" "$inside" >"$DSV_DIR/$ds" || { rm -f "$DSV_DIR/$ds"; exit 1; } fi fi @@ -161,7 +165,7 @@ search() if $path; then echo "`pwd`/$DSV_DIR/$file" else - ${DSV_PDFVIEWER:-xpdf} "$DSV_DIR/$file" + ${DSV_VIEWER:-${DSV_PDFVIEWER:-xdg-open}} "$DSV_DIR/$file" fi exit fi