From 20611c7c15aede0f991114256b230a34e99b4c5f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 28 May 2018 10:11:19 +0530 Subject: [PATCH] Add a convenience option to kitty icat to print the screen size --- kittens/icat/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kittens/icat/main.py b/kittens/icat/main.py index 6d936a039..61f664a6e 100755 --- a/kittens/icat/main.py +++ b/kittens/icat/main.py @@ -74,6 +74,13 @@ type=float default=10 The amount of time (in seconds) to wait for a response form the terminal, when detecting image display support. + + +--print-screen-size +type=bool-set +Print out the screen size as |_ widthxheight| (in pixels) and quit. This is a +convenience method to query the screen size if using kitty icat from a +scripting language that cannot make termios calls. ''' @@ -245,6 +252,10 @@ def main(args=sys.argv): ' Directories are scanned recursively for image files.') args, items = parse_args(args[1:], options_spec, 'image-file ...', msg, '{} icat'.format(appname)) + if args.print_screen_size: + print('{}x{}'.format(screen_size().width, screen_size().height)) + raise SystemExit(0) + signal.signal(signal.SIGWINCH, lambda signum, frame: setattr(screen_size, 'changed', True)) if not sys.stdout.isatty() or not sys.stdin.isatty(): raise SystemExit(