From 78b5c0a77e64b88847d079aade5eae5cc754775c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 28 Sep 2022 10:14:02 +0200 Subject: [PATCH] swaymsg: show mode picture aspect ratio --- swaymsg/main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/swaymsg/main.c b/swaymsg/main.c index c4e2b0bf..c0b5809e 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c @@ -271,14 +271,22 @@ static void pretty_print_output(json_object *o) { for (size_t i = 0; i < modes_len; ++i) { json_object *mode = json_object_array_get_idx(modes, i); - json_object *mode_width, *mode_height, *mode_refresh; + json_object *mode_width, *mode_height, *mode_refresh, + *mode_picture_aspect_ratio; json_object_object_get_ex(mode, "width", &mode_width); json_object_object_get_ex(mode, "height", &mode_height); json_object_object_get_ex(mode, "refresh", &mode_refresh); + json_object_object_get_ex(mode, "picture_aspect_ratio", + &mode_picture_aspect_ratio); - printf(" %dx%d @ %.3f Hz\n", json_object_get_int(mode_width), + printf(" %dx%d @ %.3f Hz", json_object_get_int(mode_width), json_object_get_int(mode_height), (double)json_object_get_int(mode_refresh) / 1000); + if (mode_picture_aspect_ratio && + strcmp("none", json_object_get_string(mode_picture_aspect_ratio)) != 0) { + printf(" (%s)", json_object_get_string(mode_picture_aspect_ratio)); + } + printf("\n"); } }