ansiweather

Weather in terminal, with ANSI colors and Unicode symbols
Log | Files | Refs | README | LICENSE

commit a327e768d90b50845980821ff0ebf78ef5920042
parent 0bc59b9a970b6f9b97cf70ca15f6b78cfe2f8571
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Sat,  2 Nov 2013 00:48:34 +0100

Removing unnecessary IP address lookup

Diffstat:
Mansiweather | 16++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/ansiweather b/ansiweather @@ -6,7 +6,7 @@ # https://github.com/fcambus/ansiweather # # # # Created: 2013/08/29 # -# Last Updated: 2013/10/30 # +# Last Updated: 2013/11/02 # # # # AnsiWeather is released under the BSD 3-Clause license. # # See LICENSE file for details. # @@ -41,6 +41,7 @@ fetch_cmd=$(get_config "fetch_cmd" || echo "curl -s") ###[ Check if jq is installed ]############################################### + jqpath="`which jq`" if [ "$jqpath" == "" ] then @@ -48,21 +49,16 @@ then exit 255 fi -###[ Auto-Location Logic ]################################################### -geo_locate_api="http://freegeoip.net/json/%s" #geo location service -ip_service="ifconfig.me" #ip-determination service -function get_ip_address { - echo $($fetch_cmd $ip_service) -} +###[ Auto-Location Logic ]#################################################### + +geo_locate_api="http://freegeoip.net/json/" #geo location service function auto_locate { ret="" - ip=$(get_ip_address) - - geo_data=$($fetch_cmd $(printf $geo_locate_api $ip)) + geo_data=$($fetch_cmd $geo_locate_api) city=$(echo $geo_data | jq -r '.city')