Skip to content

Instantly share code, notes, and snippets.

@timja
Created December 2, 2018 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timja/9113fb331f44827c268616d9384a8c8a to your computer and use it in GitHub Desktop.
Save timja/9113fb331f44827c268616d9384a8c8a to your computer and use it in GitHub Desktop.
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