def main(args): try: remote_control.main([ '', 'resize-window', '--self', '--axis=vertical', '--increment', '-100' ]) except: pass error = '' if len(args) < 2 or not args[1].isdigit(): error = 'Error: Window id must be provided as the first argument.' window_id = int(args[1]) window_ids = [window_id] if len(args) > 2 and args[2] == '--all-windows': ls_output = run(['kitty', '@', 'ls'], stdout=PIPE) ls_json = json.loads(ls_output.stdout.decode()) current_tab = None for os_window in ls_json: for tab in os_window['tabs']: for kitty_window in tab['windows']: if kitty_window['id'] == window_id: current_tab = tab if current_tab: window_ids = [ w['id'] for w in current_tab['windows'] if not w['is_focused'] ] else: error = 'Error: Could not find the window id provided.' loop = Loop() with cached_values_for('search') as cached_values: handler = Search(cached_values, window_ids, error) loop.loop(handler)
def main(args: List[str]) -> None: try: cli_opts, items = parse_themes_args(args[1:]) except SystemExit as e: if e.code != 0: print(e.args[0], file=sys.stderr) input(_('Press Enter to quit')) return None if len(items) > 1: items = [' '.join(items)] if len(items) == 1: return non_interactive(cli_opts, items[0]) loop = Loop() with cached_values_for('themes-kitten') as cached_values: handler = ThemesHandler(cached_values, cli_opts) loop.loop(handler) if loop.return_code != 0: if handler.report_traceback_on_exit: print(handler.report_traceback_on_exit, file=sys.stderr) input('Press Enter to quit.') if handler.state is State.fetching: # asyncio uses non-daemonic threads in its ThreadPoolExecutor # so we will hang here till the download completes without # os._exit os._exit(loop.return_code) raise SystemExit(loop.return_code)
def main(args): loop = Loop() with cached_values_for('unicode-input') as cached_values: handler = UnicodeInput(cached_values) loop.loop(handler) if handler.current_char and loop.return_code == 0: with suppress(Exception): handler.recent.remove(ord(handler.current_char)) recent = [ord(handler.current_char)] + handler.recent cached_values['recent'] = recent[:len(DEFAULT_SET)] return handler.current_char if loop.return_code != 0: raise SystemExit(loop.return_code)
def main(args=sys.argv): loop = Loop() with cached_values_for('unicode-input') as cached_values: handler = UnicodeInput(cached_values) loop.loop(handler) if handler.current_char and loop.return_code == 0: print('OK:', hex(ord(handler.current_char))[2:]) try: handler.recent.remove(ord(handler.current_char)) except Exception: pass recent = [ord(handler.current_char)] + handler.recent cached_values['recent'] = recent[:len(DEFAULT_SET)] raise SystemExit(loop.return_code)
def main(args): try: args, items = parse_unicode_input_args(args[1:]) except SystemExit as e: if e.code != 0: print(e.args[0], file=sys.stderr) input(_('Press Enter to quit')) return loop = Loop() with cached_values_for('unicode-input') as cached_values: handler = UnicodeInput(cached_values, args.emoji_variation) loop.loop(handler) if handler.current_char and loop.return_code == 0: with suppress(Exception): handler.recent.remove(ord(handler.current_char)) recent = [ord(handler.current_char)] + handler.recent cached_values['recent'] = recent[:len(DEFAULT_SET)] return handler.resolved_current_char if loop.return_code != 0: raise SystemExit(loop.return_code)
def main(args: List[str]) -> Optional[str]: try: cli_opts, items = parse_unicode_input_args(args[1:]) except SystemExit as e: if e.code != 0: report_unhandled_error(e.args[0]) return None loop = Loop() with cached_values_for('unicode-input') as cached_values: handler = UnicodeInput(cached_values, cli_opts.emoji_variation) loop.loop(handler) if handler.current_char and loop.return_code == 0: with suppress(Exception): handler.recent.remove(ord(handler.current_char)) recent = [ord(handler.current_char)] + handler.recent cached_values['recent'] = recent[:len(DEFAULT_SET)] return handler.resolved_current_char if loop.return_code != 0: raise SystemExit(loop.return_code) return None