Add a convenience option to kitty icat to print the screen size
This commit is contained in:
parent
8dea5b3e3e
commit
20611c7c15
@ -74,6 +74,13 @@ type=float
|
|||||||
default=10
|
default=10
|
||||||
The amount of time (in seconds) to wait for a response form the terminal, when
|
The amount of time (in seconds) to wait for a response form the terminal, when
|
||||||
detecting image display support.
|
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.')
|
' Directories are scanned recursively for image files.')
|
||||||
args, items = parse_args(args[1:], options_spec, 'image-file ...', msg, '{} icat'.format(appname))
|
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))
|
signal.signal(signal.SIGWINCH, lambda signum, frame: setattr(screen_size, 'changed', True))
|
||||||
if not sys.stdout.isatty() or not sys.stdin.isatty():
|
if not sys.stdout.isatty() or not sys.stdin.isatty():
|
||||||
raise SystemExit(
|
raise SystemExit(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user