From fcf618f21e67f584ecb3bb038ad99858d0b92324 Mon Sep 17 00:00:00 2001 From: robhh Date: Mon, 11 Mar 2013 00:49:04 -0300 Subject: [PATCH 1/4] Remote support Added remote support for iTunes and Keynote --- p.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/p.py b/p.py index 53bb407..5b4272c 100755 --- a/p.py +++ b/p.py @@ -54,6 +54,12 @@ def cmd_get_time(pebble, args): def cmd_set_time(pebble, args): pebble.set_time(args.timestamp) +def cmd_remote(pebble, args): + pebble.remote(args.app) + #keep open to receive remote events + while True: + time.sleep(1) + def main(): parser = argparse.ArgumentParser(description='a utility belt for pebble development') parser.add_argument('--pebble_id', type=str, help='the last 4 digits of the target Pebble\'s MAC address') @@ -102,6 +108,10 @@ def main(): set_time_parser.add_argument('timestamp', type=int, help='time stamp to be sent') set_time_parser.set_defaults(func=cmd_set_time) + remote_parser = subparsers.add_parser('remote', help='remote control Mac applications') + remote_parser.add_argument('app', metavar='APP', choices=('itunes', 'keynote'), type=str, help='either itunes or keynote') + remote_parser.set_defaults(func=cmd_remote) + args = parser.parse_args() attempts = 0 From e90d832cb9b7817cac98a9ce435a6e4a2b8c0a71 Mon Sep 17 00:00:00 2001 From: robhh Date: Mon, 11 Mar 2013 00:55:18 -0300 Subject: [PATCH 2/4] Added remote support for iTunes and Keynote Added remote support for iTunes and Keynote --- pebble/pebble.py | 70 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/pebble/pebble.py b/pebble/pebble.py index 807146c..46ebccc 100755 --- a/pebble/pebble.py +++ b/pebble/pebble.py @@ -108,6 +108,49 @@ class Pebble(object): to the watch through an instance of this class. """ + _remote_commands = { + "ITUNES": [ + """ + osascript -e 'tell application "System Events" + tell application "iTunes" to activate + key code 49 + end tell' + """, + """ + osascript -e 'tell application "System Events" + tell application "iTunes" to activate + key code 124 using command down + end tell' + """, + """ + osascript -e 'tell application "System Events" + tell application "iTunes" to activate + key code 123 using command down + end tell' + """ + ], + "KEYNOTE": [ + """ + osascript -e 'tell application "System Events" + tell application "Keynote" to activate + key code 35 using {command down, option down} + end tell' + """, + """ + osascript -e 'tell application "System Events" + tell application "Keynote" to activate + key code 124 using command down + end tell' + """, + """ + osascript -e 'tell application "System Events" + tell application "Keynote" to activate + key code 123 using command down + end tell' + """ + ] + } + endpoints = { "TIME": 11, "VERSION": 16, @@ -156,7 +199,8 @@ def __init__(self, id = None): self.endpoints["SYSTEM_MESSAGE"]: self._system_message_response, self.endpoints["LOGS"]: self._log_response, self.endpoints["PING"]: self._ping_response, - self.endpoints["APP_MANAGER"]: self._appbank_status_response + self.endpoints["APP_MANAGER"]: self._appbank_status_response, + self.endpoints["MUSIC_CONTROL"]: self._remote_response } try: @@ -168,6 +212,8 @@ def __init__(self, id = None): # we get a null response when we connect, discard it self._ser.read(5) + self._ser.write("\x00\x0d\x00\x11\x01\xff\xff\xff\xff\x80\x00\x00\x00\x00\x00\x00\x32") + # Eat any cruft that might be sitting in the serial buffer... while self._ser.read(): pass @@ -467,6 +513,28 @@ def disconnect(self): self._alive = False self._ser.close() + def remote(self, remote_app): + app_string = { + "ITUNES" : "iTunes", + "KEYNOTE" : "Keynote" + } + self._remote_app = remote_app.upper() + log.info("Remote: Control " + app_string[self._remote_app] + " with Pebble" ) + self.set_nowplaying_metadata(app_string[self._remote_app], "libpebble", "Pebble") + + + def _remote_response(self, endpoint, data): + res, = unpack("!b", data) +# log.info("Remote: %s" % res) + cmd = "" + if res == 1: + cmd = self._remote_commands[self._remote_app][0] + elif res == 4: + cmd = self._remote_commands[self._remote_app][1] + elif res == 5: + cmd = self._remote_commands[self._remote_app][2] + os.system(cmd) + def _add_app(self, index): data = pack("!bI", 3, index) self._send_message("APP_MANAGER", data) From 23ae75ec687c53b8a05f86d08df3236e3dff2288 Mon Sep 17 00:00:00 2001 From: Chi Trung Nguyen Date: Wed, 13 Mar 2013 08:14:27 +0100 Subject: [PATCH 3/4] updated status for remote iTunes and Keynote support --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9dcc990..3cd4f2a 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ The following are currently supported: * Getting the installed firmware versions * Installing firmware * Getting device data (serial, BT MAC etc) +* Remote support for Keynote and iTunes REPL ---- From 4e4d7133fef40887ef534925adb8eb0c3455e080 Mon Sep 17 00:00:00 2001 From: virtualswede Date: Thu, 4 Apr 2013 15:03:57 +0200 Subject: [PATCH 4/4] Added Microsoft PowerPoint 2011 remote functionality Have PowerPoint open with a presentation loaded, run the script, then press the middle button to START the presentation, press the upper button to go to NEXT SLIDE, and press the bottom button to go to PREVIOUS SLIDE. --- p.py | 2 +- pebble/pebble.py | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/p.py b/p.py index 5b4272c..8f9a6eb 100755 --- a/p.py +++ b/p.py @@ -109,7 +109,7 @@ def main(): set_time_parser.set_defaults(func=cmd_set_time) remote_parser = subparsers.add_parser('remote', help='remote control Mac applications') - remote_parser.add_argument('app', metavar='APP', choices=('itunes', 'keynote'), type=str, help='either itunes or keynote') + remote_parser.add_argument('app', metavar='APP', choices=('itunes', 'keynote', 'powerpoint'), type=str, help='either itunes or keynote') remote_parser.set_defaults(func=cmd_remote) args = parser.parse_args() diff --git a/pebble/pebble.py b/pebble/pebble.py index 46ebccc..503f128 100755 --- a/pebble/pebble.py +++ b/pebble/pebble.py @@ -148,7 +148,27 @@ class Pebble(object): key code 123 using command down end tell' """ - ] + ], + "POWERPOINT": [ + """ + osascript -e 'tell application "Microsoft PowerPoint" + activate + run slide show slide show settings of active presentation + end tell' + """, + """ + osascript -e 'tell application "Microsoft PowerPoint" + activate + go to next slide slide show view of slide show window 1 + end tell' + """, + """ + osascript -e 'tell application "Microsoft PowerPoint" + activate + go to previous slide slide show view of slide show window 1 + end tell' + """ + ] } endpoints = { @@ -516,7 +536,8 @@ def disconnect(self): def remote(self, remote_app): app_string = { "ITUNES" : "iTunes", - "KEYNOTE" : "Keynote" + "KEYNOTE" : "Keynote", + "POWERPOINT" : "PowerPoint" } self._remote_app = remote_app.upper() log.info("Remote: Control " + app_string[self._remote_app] + " with Pebble" )