dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 312051e49165911d8c66e0f3767b5974fae30180
parent af9e7f52fac0e84c221756b80ef68ae6bf3479ee
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Sun, 23 Jun 2019 21:40:36 +0200

Generalize comic script

Diffstat:
M.config/newsboat/config | 2+-
A.local/bin/comic | 18++++++++++++++++++
D.local/bin/smbc | 10----------
3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/.config/newsboat/config b/.config/newsboat/config @@ -68,4 +68,4 @@ macro y set browser "echo -n %u | xclip -selection clipboard" ; open-in-browser macro p set browser "wkhtmltopdf %u out.pdf && mv out.pdf ~/tmp/$(basename $(mktemp)).pdf" ; open-in-browser ; set browser xdg-open macro u set browser "curl -L %u | grep -i '\.pdf' | urlview" ; open-in-browser ; set browser xdg-open macro s set browser "cd ~/tmp && tsp shdl -t -n -o %u" ; open-in-browser ; set browser xdg-open -macro c set browser "cd ~/tmp && smbc %u" ; open-in-browser ; toggle-article-read ; set browser xdg-open +macro c set browser "cd ~/tmp && comic %u" ; open-in-browser ; toggle-article-read ; set browser xdg-open diff --git a/.local/bin/comic b/.local/bin/comic @@ -0,0 +1,18 @@ +#!/bin/sh +set -eu + +url="${1:-https://www.smbc-comics.com/}" + +case "$url" in + *smbc*) + f="$(curl -s --write-out "%{filename_effective}\n" -OL \ + "$(curl -s -L "$url" | \ + grep '.png' | sed 1q | sed 's/^.*https/https/;s/".*$//')")";; + *xkcd*) + f="$(curl -s --write-out "%{filename_effective}\n" -OL \ + "$(curl -s -L "$url" | \ + grep 'Image URL' | sed 1q | sed 's/^.*https/https/;s/".*$//')")";; +esac + +xdg-open "$f" +rm "$f" diff --git a/.local/bin/smbc b/.local/bin/smbc @@ -1,10 +0,0 @@ -#!/bin/sh -set -eu - -url="${1:-https://www.smbc-comics.com/}" -f="$(curl -s --write-out "%{filename_effective}\n" -OL \ -"$(curl -s -L "$url" | \ -grep '.png' | sed 1q | sed 's/^.*https/https/;s/".*$//')")" - -xdg-open "$f" -rm "$f"