mirror of
https://github.com/danbulant/nekofetch
synced 2026-07-07 20:10:43 +00:00
Make script POSIX compliant
This commit is contained in:
parent
1bf621efc7
commit
c6e1f07bbe
1 changed files with 14 additions and 24 deletions
38
nekofetch
38
nekofetch
|
|
@ -1,32 +1,22 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ ! command -v jp2a &> /dev/null ]; then
|
required="neofetch jp2a jq"
|
||||||
echo "jp2a not found!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! command -v neofetch &> /dev/null ]; then
|
for req in $required; do
|
||||||
echo "neofetch not found!"
|
! command -v "$req" > /dev/null 2>&1 && echo "$req not found!" && exit 1
|
||||||
exit 1
|
done
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! command -v jq &> /dev/null ]; then
|
|
||||||
echo "jq not found!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
[[ ! -d "/tmp/nekofetch" ]] && mkdir /tmp/nekofetch
|
tmpfile="$(mktemp -p /tmp nekofetchXXXXXXXX)"
|
||||||
|
|
||||||
if [[ "$1" = "--nsfw" ]]; then
|
if [ "$1" = "--nsfw" ]; then
|
||||||
url=$(curl "https://nekos.life/api/v2/img/cum_jpg" | jq -r ".url")
|
url=$(curl -fsSL "https://nekos.life/api/v2/img/cum_jpg" | jq -r ".url")
|
||||||
curl -fsSLo "/tmp/nekofetch/neko.jpg" "$url"
|
|
||||||
|
|
||||||
jp2a /tmp/nekofetch/neko.jpg > /tmp/nekofetch/neko
|
|
||||||
neofetch --source /tmp/nekofetch/neko
|
|
||||||
else
|
else
|
||||||
url=$(curl "https://nekos.life/api/v2/img/neko" | jq -r ".url")
|
url=$(curl -fsSL "https://nekos.life/api/v2/img/neko" | jq -r ".url")
|
||||||
curl -fsSLo "/tmp/nekofetch/neko.jpg" "$url"
|
|
||||||
|
|
||||||
jp2a /tmp/nekofetch/neko.jpg > /tmp/nekofetch/neko
|
|
||||||
neofetch --source /tmp/nekofetch/neko
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
curl -fsSLo "$tmpfile.jpg" "$url"
|
||||||
|
jp2a "$tmpfile.jpg" > "$tmpfile"
|
||||||
|
neofetch --source "$tmpfile"
|
||||||
|
|
||||||
|
rm "$tmpfile" "$tmpfile.jpg"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue