From 8d8694fd082b9a7e106a6d7067eac373ce18e90e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 2 Jun 2022 17:44:25 +0200 Subject: [PATCH] tools/get-state: Add --short Often, most of the output consists of a long list of exposed modes for each monitor. If --short is passed, only pass modes that has properties. In practice, this means "preferred" modes, "current" modes, and similarly special cases, which significantly reduces noise. Part-of: --- tools/get-state.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/get-state.py b/tools/get-state.py index 79d017346..b721e3d4e 100755 --- a/tools/get-state.py +++ b/tools/get-state.py @@ -16,6 +16,7 @@ class Source(enum.Enum): parser = argparse.ArgumentParser(description='Get display state') parser.add_argument('file', metavar='FILE', type=str, nargs='?', help='Read the output from gdbus call instead of calling D-Bus') +parser.add_argument('--short', action='store_true') args = parser.parse_args() @@ -25,6 +26,8 @@ if args.file: else: source = Source.DBUS +short = args.short + type_signature = '(ua((ssss)a(siiddada{sv})a{sv})a(iiduba(ssss)a{sv})a{sv})' variant_type = GLib.VariantType.new(type_signature) @@ -106,7 +109,15 @@ for monitor in monitors: properties = monitor[2] print_data(0, is_last, lines, 'Monitor {}'.format(spec[0])) print_data(1, False, lines, f'EDID: vendor: {spec[1]}, product: {spec[2]}, serial: {spec[3]}') - print_data(1, False, lines, f'Modes ({len(modes)})') + + mode_count = len(modes) + if short: + modes = [mode for mode in modes if len(mode[6]) > 0] + print_data(1, False, lines, + f'Modes ({len(modes)}, {mode_count - len(modes)} omitted)') + else: + print_data(1, False, lines, + f'Modes ({len(modes)})') for mode in modes: is_last = mode == modes[-1]