mirror of
https://github.com/danbulant/nekofetch
synced 2026-05-24 12:22:00 +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
51
nekofetch
51
nekofetch
|
|
@ -1,24 +1,61 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
tmpfile="$(mktemp)"
|
tmpfile="$(mktemp)"
|
||||||
|
imgtype=""
|
||||||
|
use_height=""
|
||||||
|
|
||||||
|
while :; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"--nsfw"|"nsfw"|"-n"|"n")
|
"--nsfw"|"nsfw"|"-n"|"n")
|
||||||
|
if [ "$imgtype" = "" ]; then
|
||||||
[ "$DEBUG" = "true" ] && echo "Getting a nsfw image"
|
[ "$DEBUG" = "true" ] && echo "Getting a nsfw image"
|
||||||
imgurl="https://nekos.life/api/v2/img/cum_jpg"
|
imgtype="nsfw"
|
||||||
|
else
|
||||||
|
echo "$imgtype images were already chosen! Please only specify either sfw or nsfw!"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
"--sfw"|"sfw"|"-s"|"s")
|
"--sfw"|"sfw"|"-s"|"s")
|
||||||
|
if [ "$imgtype" = "" ]; then
|
||||||
[ "$DEBUG" = "true" ] && echo "Getting a sfw image"
|
[ "$DEBUG" = "true" ] && echo "Getting a sfw image"
|
||||||
imgurl="https://nekos.life/api/v2/img/neko"
|
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
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
[ "$DEBUG" = "true" ] && echo "Could not interpret as either sfw or nsfw. Defaulting to sfw."
|
if [ -z "$1" ]; then
|
||||||
imgurl="https://nekos.life/api/v2/img/neko"
|
break
|
||||||
|
fi
|
||||||
|
echo "Could not interpret parameter '$1'."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
echo "$2" | grep -qE '^[0-9]+$' && height="$2" || height="$(($(stty size | awk '{print $1}') - 5))"
|
if [ "$imgtype" = "nsfw" ]; then
|
||||||
[ "$DEBUG" = "true" ] && echo "Using height $height"
|
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")
|
url=$(curl -fsSL "$imgurl" | jq -r ".url")
|
||||||
|
|
||||||
|
|
@ -31,6 +68,8 @@ if [ "$TERM" = "xterm-kitty" ]; then
|
||||||
fi
|
fi
|
||||||
elif [ "$LC_TERMINAL" = "iTerm2" ]; then
|
elif [ "$LC_TERMINAL" = "iTerm2" ]; then
|
||||||
neofetch --iterm2 "$tmpfile.jpg"
|
neofetch --iterm2 "$tmpfile.jpg"
|
||||||
|
elif [ "$use_w3m" = "true" ]; then
|
||||||
|
neofetch --w3m "$tmpfile.jpg"
|
||||||
else
|
else
|
||||||
jp2a --height="$height" "$tmpfile.jpg" > "$tmpfile"
|
jp2a --height="$height" "$tmpfile.jpg" > "$tmpfile"
|
||||||
neofetch --source "$tmpfile"
|
neofetch --source "$tmpfile"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue