nekofetch/nekofetch
BBaoVanC e63738e9e2
Switch GitHub Actions jobs to use Makefile (#3)
* Move nekofetch to root of repository

* Add Makefile

* Use Makefile for CI and CD jobs
2021-01-05 20:55:47 -06:00

36 lines
943 B
Bash
Executable file

#!/bin/sh
required="neofetch jp2a jq curl"
for req in $required; do
! command -v "$req" > /dev/null 2>&1 && echo "$req not found!" && exit 1
done
tmpfile="$(mktemp -p /tmp nekofetchXXXXXXXX)"
case "$1" in
"--nsfw"|"nsfw"|"-n"|"n")
echo "Getting a nsfw image"
imgurl="https://nekos.life/api/v2/img/cum_jpg"
;;
"--sfw"|"sfw"|"-s"|"s")
echo "Getting a sfw image"
imgurl="https://nekos.life/api/v2/img/neko"
;;
*)
echo "Could not interpret as either sfw or nsfw. Defaulting to sfw."
imgurl="https://nekos.life/api/v2/img/neko"
;;
esac
echo "$2" | grep -qE '^[0-9]+$' && height="$2" || height="$(($(stty size | awk '{print $1}') - 5))"
echo "Using height $height"
url=$(curl -fsSL "$imgurl" | jq -r ".url")
curl -fsSLo "$tmpfile.jpg" "$url"
jp2a --height="$height" "$tmpfile.jpg" > "$tmpfile"
neofetch --source "$tmpfile"
rm "$tmpfile" "$tmpfile.jpg"