Update sb-iplocate

This commit is contained in:
HelionSmoker 2023-04-02 19:05:29 +03:00 committed by GitHub
parent 5a6c56d565
commit 6dd6fac293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,12 @@
#!/bin/sh #!/bin/sh
# Gets your public ip address checks which country you are in and # Displays the flag of the country you are in based on your public ip adress
# displays that information in the statusbar
# #
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/ # https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
ifinstalled "geoip" || exit ifinstalled "geoip" || exit
addr="$(curl ifconfig.me 2>/dev/null)" || 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/;.*//" country="$(geoiplookup "$addr" | sed -e 's/^[^,]*, //' -e 's/,.*$//')" # Keep only between 1st and 2nd comma
grep "flag: $country" "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/chars/emoji" |
sed 's/flag:.*//' # Remove everything from 'flag:' onward