summary refs log tree commit diff
path: root/geolocate
diff options
context:
space:
mode:
Diffstat (limited to 'geolocate')
-rwxr-xr-xgeolocate13
1 files changed, 13 insertions, 0 deletions
diff --git a/geolocate b/geolocate
index b11846f..674d242 100755
--- a/geolocate
+++ b/geolocate
@@ -35,6 +35,15 @@ curl -s https://ipvigilante.com/ | \
         done
 }
 
+printCoord() {
+curl -s https://ipvigilante.com/ | \
+        jq '.data.latitude, .data.longitude' | \
+        while read -r LATITUDE; do
+                read -r LONGITUDE
+                echo "${LATITUDE}:${LONGITUDE}" | tr -d '"' > /usr/share/geolocate/.location
+        done
+}
+
         main() {
 
             case "$1" in
@@ -65,6 +74,10 @@ curl -s https://ipvigilante.com/ | \
                   esac
                   exit 0
                 ;;
+            print)
+                printCoord
+                exit 0
+                ;;
             *)
                 getCoord
                 exit 0