aboutsummaryrefslogtreecommitdiff
path: root/tools/EventClients/Clients
diff options
context:
space:
mode:
authorDániel Zoltán Tolnai <danielz.tolnai@gmail.com>2018-04-22 14:32:01 +0200
committerDániel Zoltán Tolnai <danielz.tolnai@gmail.com>2018-06-07 21:21:11 +0200
commit8b52a958af5f9229aaf3971f4643c491e7d878a6 (patch)
tree00c089f21dcfc8ed58192abde04fd84e72c639cc /tools/EventClients/Clients
parentdee05003f5d0e234ff5616bd14168c9169cd9acd (diff)
kodi-send: Add option to send a key press event
Diffstat (limited to 'tools/EventClients/Clients')
-rwxr-xr-xtools/EventClients/Clients/KodiSend/kodi-send.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/tools/EventClients/Clients/KodiSend/kodi-send.py b/tools/EventClients/Clients/KodiSend/kodi-send.py
index c114a22b3b..16e1863f80 100755
--- a/tools/EventClients/Clients/KodiSend/kodi-send.py
+++ b/tools/EventClients/Clients/KodiSend/kodi-send.py
@@ -29,19 +29,23 @@ except:
from xbmcclient import *
def usage():
- print("kodi-send [OPTION] --action=ACTION")
+ print("Usage")
+ print("\tkodi-send [OPTION] --action=ACTION")
+ print("\tkodi-send [OPTION] --button=BUTTON")
print('Example')
print('\tkodi-send --host=192.168.0.1 --port=9777 --action="Quit"')
print("Options")
print("\t-?, --help\t\t\tWill bring up this message")
print("\t--host=HOST\t\t\tChoose what HOST to connect to (default=localhost)")
print("\t--port=PORT\t\t\tChoose what PORT to connect to (default=9777)")
+ 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')
print('\t--action=ACTION\t\t\tSends an action to XBMC, 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=", "action="])
+ opts, args = getopt.getopt(sys.argv[1:], "?pa:v", ["help", "host=", "port=", "keymap=", "button=", "action="])
except getopt.GetoptError as err:
# print help information and exit:
print(str(err)) # will print something like "option -a not recognized"
@@ -49,6 +53,8 @@ def main():
sys.exit(2)
ip = "localhost"
port = 9777
+ keymap = "KB"
+ button = ""
actions = []
verbose = False
for o, a in opts:
@@ -59,6 +65,10 @@ def main():
ip = a
elif o == "--port":
port = int(a)
+ elif o == "--keymap":
+ keymap = a
+ elif o == "--button":
+ button = a
elif o in ("-a", "--action"):
actions.append(a)
else:
@@ -67,7 +77,7 @@ def main():
addr = (ip, port)
sock = socket(AF_INET,SOCK_DGRAM)
- if len(actions) is 0:
+ if len(actions) is 0 and button is "":
usage()
sys.exit(0)
@@ -76,5 +86,10 @@ def main():
packet = PacketACTION(actionmessage=action, actiontype=ACTION_BUTTON)
packet.send(sock, addr)
+ if button is not "":
+ print('Sending key press: %s' % button)
+ packet = PacketBUTTON(code=0, repeat=0, down=1, map_name=keymap, button_name=button, amount=0)
+ packet.send(sock, addr)
+
if __name__=="__main__":
main()