diff options
author | Dániel Zoltán Tolnai <danielz.tolnai@gmail.com> | 2018-05-01 16:50:49 +0200 |
---|---|---|
committer | Dániel Zoltán Tolnai <danielz.tolnai@gmail.com> | 2018-06-07 21:21:17 +0200 |
commit | 1337e0394b4e0977357ca4257c522dee80aea718 (patch) | |
tree | ea60c349b532e1e581ed04a38815f8f59840e8c5 /tools/EventClients | |
parent | df392010132bf6069a83a70007c442696a7460f5 (diff) |
kodi-send: Add option to wait for a given time in macros
Diffstat (limited to 'tools/EventClients')
-rwxr-xr-x | tools/EventClients/Clients/KodiSend/kodi-send.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/EventClients/Clients/KodiSend/kodi-send.py b/tools/EventClients/Clients/KodiSend/kodi-send.py index 84a2b0285a..2eebc556b7 100755 --- a/tools/EventClients/Clients/KodiSend/kodi-send.py +++ b/tools/EventClients/Clients/KodiSend/kodi-send.py @@ -22,6 +22,7 @@ import sys, os import getopt from socket import * +from time import sleep try: from kodi.xbmcclient import * except: @@ -30,6 +31,7 @@ except: TYPE_ACTION = 'action' TYPE_BUTTON = 'button' +TYPE_DELAY = 'delay' def usage(): print("Usage") @@ -44,11 +46,12 @@ def usage(): print("\t--keymap=KEYMAP\t\t\tChoose which KEYMAP to use for key presses (default=KB)") print('\t--button=BUTTON\t\t\tSends a key press event to Kodi, this option can be added multiple times to create a macro') print('\t--action=ACTION\t\t\tSends an action to XBMC, this option can be added multiple times to create a macro') + print('\t-d T, --delay=T\t\t\tWaits for T ms, this option can be added multiple times to create a macro') pass def main(): try: - opts, args = getopt.getopt(sys.argv[1:], "?pa:v", ["help", "host=", "port=", "keymap=", "button=", "action="]) + opts, args = getopt.getopt(sys.argv[1:], "?pad:v", ["help", "host=", "port=", "keymap=", "button=", "action=", "delay="]) except getopt.GetoptError as err: # print help information and exit: print(str(err)) # will print something like "option -a not recognized" @@ -73,6 +76,8 @@ def main(): actions.append({'type': TYPE_BUTTON, 'content': a}) elif o in ("-a", "--action"): actions.append({'type': TYPE_ACTION, 'content': a}) + elif o in ("-d", "--delay"): + actions.append({'type': TYPE_DELAY, 'content': int(a)}) else: assert False, "unhandled option" @@ -89,6 +94,9 @@ def main(): packet = PacketACTION(actionmessage=action['content'], actiontype=ACTION_BUTTON) elif action['type'] == TYPE_BUTTON: packet = PacketBUTTON(code=0, repeat=0, down=1, queue=1, map_name=keymap, button_name=action['content'], amount=0) + elif action['type'] == TYPE_DELAY: + time.sleep(action['content'] / 1000.0) + continue packet.send(sock, addr, uid=0) if __name__=="__main__": |