use built-ins, close #1297

This commit is contained in:
Luke Smith 2023-04-20 08:47:39 -04:00
parent 5a6c56d565
commit b719590427
No known key found for this signature in database
GPG key ID: 4C50B54A911F6252

View file

@ -5,6 +5,11 @@
# #
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/ # https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
ifinstalled "geoip" || exit set -e
addr="$(curl ifconfig.me 2>/dev/null)" || exit
grep "flag: " "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji" | grep "$(geoiplookup "$addr" | sed 's/.*, //')" | sed "s/flag: //;s/;.*//" ifinstalled "geoip"
addr="$(geoiplookup "$(curl -sfm 1 ifconfig.me 2>/dev/null)")"
name="${addr##*, }"
flag="$(grep "flag: $name" "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji")"
flag="${flag%% *}"
printf "%s %s\\n" "$flag" "$name"