From b719590427681e977b2a13e8490971e1e1b166b8 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Thu, 20 Apr 2023 08:47:39 -0400 Subject: [PATCH] use built-ins, close #1297 --- .local/bin/statusbar/sb-iplocate | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.local/bin/statusbar/sb-iplocate b/.local/bin/statusbar/sb-iplocate index 02adab8..a9043e3 100755 --- a/.local/bin/statusbar/sb-iplocate +++ b/.local/bin/statusbar/sb-iplocate @@ -5,6 +5,11 @@ # # https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/ -ifinstalled "geoip" || exit -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/;.*//" +set -e + +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"