diff --git a/kitty/rc/send_text.py b/kitty/rc/send_text.py index 97ca52440..1a583cb7b 100644 --- a/kitty/rc/send_text.py +++ b/kitty/rc/send_text.py @@ -67,22 +67,17 @@ def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: Arg def pipe() -> CmdGenerator: if sys.stdin.isatty(): ret['exclude_active'] = True - import select - fd = sys.stdin.fileno() keep_going = True - while keep_going: - rd = select.select([fd], [], [])[0] - if not rd: - break - data = os.read(fd, limit) - if not data: - break # eof - decoded_data = data.decode('utf-8') - if '\x04' in decoded_data: - decoded_data = decoded_data[:decoded_data.index('\x04')] - keep_going = False - ret['data'] = 'text:' + decoded_data - yield ret + from kitty.utils import TTYIO + with TTYIO() as tty: + while keep_going: + data = os.read(tty.tty_fd, limit) + decoded_data = data.decode('utf-8') + if '\x04' in decoded_data: + decoded_data = decoded_data[:decoded_data.index('\x04')] + keep_going = False + ret['data'] = 'text:' + decoded_data + yield ret else: while True: data = sys.stdin.buffer.read(limit)