mirror of
https://github.com/danbulant/nekofetch
synced 2026-05-19 04:08:43 +00:00
Merge pull request #9 from AryToNeX/master
Proper arguments support and support w3m backend
This commit is contained in:
commit
e1e499f1dd
1 changed files with 55 additions and 16 deletions
71
nekofetch
71
nekofetch
|
|
@ -1,24 +1,61 @@
|
|||
#!/bin/sh
|
||||
|
||||
tmpfile="$(mktemp)"
|
||||
imgtype=""
|
||||
use_height=""
|
||||
|
||||
case "$1" in
|
||||
"--nsfw"|"nsfw"|"-n"|"n")
|
||||
[ "$DEBUG" = "true" ] && echo "Getting a nsfw image"
|
||||
imgurl="https://nekos.life/api/v2/img/cum_jpg"
|
||||
;;
|
||||
"--sfw"|"sfw"|"-s"|"s")
|
||||
[ "$DEBUG" = "true" ] && echo "Getting a sfw image"
|
||||
imgurl="https://nekos.life/api/v2/img/neko"
|
||||
;;
|
||||
*)
|
||||
[ "$DEBUG" = "true" ] && echo "Could not interpret as either sfw or nsfw. Defaulting to sfw."
|
||||
imgurl="https://nekos.life/api/v2/img/neko"
|
||||
;;
|
||||
esac
|
||||
while :; do
|
||||
case "$1" in
|
||||
"--nsfw"|"nsfw"|"-n"|"n")
|
||||
if [ "$imgtype" = "" ]; then
|
||||
[ "$DEBUG" = "true" ] && echo "Getting a nsfw image"
|
||||
imgtype="nsfw"
|
||||
else
|
||||
echo "$imgtype images were already chosen! Please only specify either sfw or nsfw!"
|
||||
fi
|
||||
;;
|
||||
"--sfw"|"sfw"|"-s"|"s")
|
||||
if [ "$imgtype" = "" ]; then
|
||||
[ "$DEBUG" = "true" ] && echo "Getting a sfw image"
|
||||
imgtype="sfw"
|
||||
else
|
||||
echo "$imgtype images were already chosen! Please only specify either sfw or nsfw!"
|
||||
fi
|
||||
;;
|
||||
"--w3m"|"w3m"|"--img"|"img"|"-i"|"i")
|
||||
[ "$DEBUG" = "true" ] && echo "Using w3m image backend for neofetch"
|
||||
use_w3m="true"
|
||||
;;
|
||||
"--height"|"-h")
|
||||
if [ "$use_height" = "" ]; then
|
||||
use_height="$2"
|
||||
[ "$DEBUG" = "true" ] && echo "Using height $height"
|
||||
else
|
||||
echo "You can only specify the height argument once!"
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
if [ -z "$1" ]; then
|
||||
break
|
||||
fi
|
||||
echo "Could not interpret parameter '$1'."
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
echo "$2" | grep -qE '^[0-9]+$' && height="$2" || height="$(($(stty size | awk '{print $1}') - 5))"
|
||||
[ "$DEBUG" = "true" ] && echo "Using height $height"
|
||||
if [ "$imgtype" = "nsfw" ]; then
|
||||
imgurl="https://nekos.life/api/v2/img/cum_jpg"
|
||||
else
|
||||
imgurl="https://nekos.life/api/v2/img/neko"
|
||||
fi
|
||||
|
||||
if [ "$use_height" != "" ]; then
|
||||
height="$use_height"
|
||||
else
|
||||
height="$(($(stty size | awk '{print $1}') - 5))"
|
||||
fi
|
||||
|
||||
url=$(curl -fsSL "$imgurl" | jq -r ".url")
|
||||
|
||||
|
|
@ -31,6 +68,8 @@ if [ "$TERM" = "xterm-kitty" ]; then
|
|||
fi
|
||||
elif [ "$LC_TERMINAL" = "iTerm2" ]; then
|
||||
neofetch --iterm2 "$tmpfile.jpg"
|
||||
elif [ "$use_w3m" = "true" ]; then
|
||||
neofetch --w3m "$tmpfile.jpg"
|
||||
else
|
||||
jp2a --height="$height" "$tmpfile.jpg" > "$tmpfile"
|
||||
neofetch --source "$tmpfile"
|
||||
|
|
|
|||
Loading…
Reference in a new issue