LIRC libraries: ircat.py

| LIRC libraries LinuxInfraredRemoteControl

ircat.py
1 #!/usr/bin/env python3
2
3 '''
4 Reference python implementation of ircat(1)
5 Run using python3 ircat.py [socket_path [lircrc path]]
6 '''
7
8 import sys
9
10 import lirc
11
12 if len(sys.argv) >= 5 or len(sys.argv) < 2:
13 sys.stderr.write("Usage: ircat.py program [lircrc path [socket path]]\n")
14 sys.exit(1)
15 socket_path = sys.argv[3] if len(sys.argv) == 4 else None
16 lircrc_path = sys.argv[2] if len(sys.argv) >= 3 else None
17 program = sys.argv[1]
18
19 with lirc.LircdConnection(program, lircrc_path, socket_path) as conn:
20 while True:
21 print(conn.readline())