Skip to content

Instantly share code, notes, and snippets.

@Damoon7
Last active December 30, 2020 16:55
Show Gist options
  • Save Damoon7/cc242dbaa45edc3460a11d21c87dcc40 to your computer and use it in GitHub Desktop.
Save Damoon7/cc242dbaa45edc3460a11d21c87dcc40 to your computer and use it in GitHub Desktop.
#!/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