Makes linkhandler handle more

It now handles some peertube, more invidious and xkcd
Jonathan Hodgson 4 years ago
parent 1da1a17c0b
commit fa4b73bc51
  1. 6
      bin/.bin/linkhandler
  2. 4
      bin/.bin/xkcd

@ -9,8 +9,12 @@ url="$1"
browser="${BROWSER:-firefox-developer-edition}" browser="${BROWSER:-firefox-developer-edition}"
case "$url" in case "$url" in
*"//invidio.us/"*) open-youtube "$url"; exit 0 ;; *"//invidious.*/"*) open-youtube "$url"; exit 0 ;;
*//*.youtube.*/*) open-youtube "$url"; exit 0 ;;
*"//videos.*"*) open-youtube "$url"; exit 0 ;;
*"//xkcd.com/"*) xkcd "$url"; exit 0 ;;
*) $browser "$url"; exit 0 ;; *) $browser "$url"; exit 0 ;;
#*) notify-send "$url"; exit ;;
esac esac
exit 1 exit 1

@ -6,9 +6,13 @@ elif [[ "$comic" == "random" ]] || [[ "$comic" == "r" ]]; then
latest=$(curl https://xkcd.com/info.0.json 2> /dev/null | /usr/bin/jq ".num") latest=$(curl https://xkcd.com/info.0.json 2> /dev/null | /usr/bin/jq ".num")
number=$(shuf -i1-$latest -n1) number=$(shuf -i1-$latest -n1)
json=$(curl https://xkcd.com/$number/info.0.json 2> /dev/null) json=$(curl https://xkcd.com/$number/info.0.json 2> /dev/null)
else
if [[ "$comic" = *"xkcd.com"* ]]; then
json=$(curl $comic/info.0.json 2> /dev/null)
else else
json=$(curl https://xkcd.com/$comic/info.0.json 2> /dev/null) json=$(curl https://xkcd.com/$comic/info.0.json 2> /dev/null)
fi fi
fi
echo $json | /usr/bin/jq -C echo $json | /usr/bin/jq -C
echo $json | /usr/bin/jq ".img" | xargs curl -s -o /tmp/xkcd echo $json | /usr/bin/jq ".img" | xargs curl -s -o /tmp/xkcd
sxiv /tmp/xkcd sxiv /tmp/xkcd

Loading…
Cancel
Save