From c8a258f36b65ff722810f7313034d575691579a8 Mon Sep 17 00:00:00 2001 From: Mena Jacobs Date: Sat, 12 Mar 2022 02:17:01 +0100 Subject: [PATCH] Fix icat fail on mac with --print-window-size passing tty as TextIOWrapper to screen_size_function results in a TypeError since the screen_size_function expects an int. calling fileno() on tty gives us the desired int. This also fixes the kitty matplotlib backend, if MPLBACEND_KITTY_SIZING is not set to manual --- kittens/icat/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kittens/icat/main.py b/kittens/icat/main.py index 2e639c725..a0f6aac82 100755 --- a/kittens/icat/main.py +++ b/kittens/icat/main.py @@ -515,7 +515,12 @@ def main(args: List[str] = sys.argv) -> None: if cli_opts.print_window_size: screen_size_function.cache_clear() with open(os.ctermid()) as tty: - ss = screen_size_function(tty)() + try: + fd = tty.fileno() + except AttributeError: + # use default value for fd if ctermid is not available + fd = None + ss = screen_size_function(fd)() print(f'{ss.width}x{ss.height}', end='') raise SystemExit(0)