Last active
December 30, 2020 16:55
-
-
Save Damoon7/cc242dbaa45edc3460a11d21c87dcc40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import json | |
import subprocess | |
from os import system | |
import time | |
from subprocess import run | |
distLat = Destination_Latitude # replace with your own | |
distLong = Destination_Longitude # replace with your own | |
system("mpv /storage/0FBE-ACFD/Musics -shuffle &") # You can replace your own program or command | |
delta=1 | |
while abs(delta) > 0.0005: | |
try: | |
sp = subprocess.Popen(["termux-location","-p","gps"],stdout=subprocess.PIPE,stderr=subprocess.PIPE,universal_newlines=True) | |
out,err=sp.communicate() | |
jdata=out | |
location=json.loads(jdata) | |
lat=location["latitude"] | |
long=location["longitude"] | |
delta=abs(lat-distLat)+abs(long-distLong) | |
#print(delta) | |
if delta<0.0004: | |
break | |
elif delta < 0.02: | |
delay=10 | |
else: | |
delay=60 | |
time.sleep(delay) | |
except Exception: | |
print(err) | |
pass | |
run("pkill mpv") | |
print("\n\n\t\t\tYou have reached your destination") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment