zero/home-environments/radio/files/.local/bin/xkcd

18 lines
374 B
Plaintext
Raw Normal View History

2024-03-23 06:11:36 +00:00
#!/bin/sh
if [ $# -gt 0 ]; then
if [ $1 = "-r" ]; then
URL=https://c.xkcd.com/random/comic
else
URL=https://xkcd.com/$1
fi
2024-03-23 06:11:36 +00:00
else
URL=https://xkcd.com/
fi
URL=$(curl -s -L $URL \
| grep 'href= "https://imgs.xkcd.com/comics.*' \
| cut -d'>' -f2 \
| cut -d'<' -f1)
curl $URL --output /tmp/xkcd 2>/dev/null
chafa /tmp/xkcd