Skip to content

Instantly share code, notes, and snippets.

@ozcan
Created December 15, 2015 09:40
Show Gist options
  • Select an option

  • Save ozcan/768c56baaa4578057002 to your computer and use it in GitHub Desktop.

Select an option

Save ozcan/768c56baaa4578057002 to your computer and use it in GitHub Desktop.
from libpebble2.communication import PebbleConnection
from libpebble2.communication.transports.serial import SerialTransport
from libpebble2.services.appmessage import *
from libpebble2.protocol import *
from libpebble2.exceptions import *
import os
pebble = PebbleConnection(SerialTransport("/dev/cu.PebbleTime189F-SerialPo"))
pebble.connect()
pebble.run_async()
def sendKeycode(keycode):
os.system("osascript -e 'tell application \"LibreOffice\" to activate'")
os.system("osascript -e 'tell application \"System Events\"' -e 'key code " + keycode + "' -e 'end tell'")
while pebble.connected:
try:
packet = pebble.read_from_endpoint(MusicControl)
if packet.command == 4:
sendKeycode("124")
elif packet.command == 5:
sendKeycode("123")
else:
print packet
except TimeoutError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment