From a64a3ee6bbd3b880c32bbd9c9a38420d04748dd2 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Sun, 10 Feb 2019 15:37:24 -0500 Subject: ipc: handle unnamed xkb_active_layout_name If the active xkb_layout does not have a name, use `NULL` instead of `json_object_new_string(NULL)`. This also makes it so swaymsg will pretty print this as `(unnamed)`. --- swaymsg/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'swaymsg') diff --git a/swaymsg/main.c b/swaymsg/main.c index c84f5671..716d2d2e 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c @@ -135,8 +135,8 @@ static void pretty_print_input(json_object *i) { json_object_get_int(vendor)); if (json_object_object_get_ex(i, "xkb_active_layout_name", &kbdlayout)) { - printf(" Active Keyboard Layout: %s\n", - json_object_get_string(kbdlayout)); + const char *layout = json_object_get_string(kbdlayout); + printf(" Active Keyboard Layout: %s\n", layout ? layout : "(unnamed)"); } if (json_object_object_get_ex(i, "libinput_send_events", &events)) { -- cgit v1.2.3