Created
December 2, 2018 15:21
-
-
Save timja/9113fb331f44827c268616d9384a8c8a to your computer and use it in GitHub Desktop.
This file contains 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
import serial | |
import json | |
import time | |
import osascript | |
s = serial.Serial('/dev/cu.usbmodem14201') | |
while True: | |
data = json.loads(s.readline()) | |
proximity = (data['detail']['proximity']) | |
if proximity > 220: | |
print("Changing track") | |
osascript.run(''' | |
tell application "Spotify" | |
next track | |
end tell | |
''') | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment