Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions android-tv-remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ def main():
return print("Please set your TV's IP-address with a --host parameter")

if args.input is None:
return print("Please set an input mode (1-6) with an --input parameter")
return print("Please set an input mode (1-6 or 'wakeup') with an --input parameter")

sources={
keycodes={
'wakeup': 'KEYCODE_WAKEUP',
1: "KEYCODE_F1",
2: "KEYCODE_F2",
3: "KEYCODE_F3",
Expand All @@ -48,13 +49,13 @@ def main():

handle_connection(args.host)

if int(args.input) in sources:
if int(args.input) in keycodes:
try:
subprocess.check_output(['adb', 'shell', 'input', 'keyevent', sources[int(args.input)]])
subprocess.check_output(['adb', 'shell', 'input', 'keyevent', keycodes[int(args.input)]])
except:
print("Error connecting to TV")
else:
print("Unknown input (should be a value between 1-6):", args.input)

if __name__ == '__main__':
main()
main()