diff options
author | Ian Fan <[email protected]> | 2018-12-09 15:10:41 +0000 |
---|---|---|
committer | Ian Fan <[email protected]> | 2018-12-31 20:40:18 +0000 |
commit | 6b03c68775c9c638def342c82b1fa3beffa52645 (patch) | |
tree | a3b18d948f8e2a51151f24aab47c552f28a17f70 /sway/ipc-json.c | |
parent | 74655f835aa9fe0e976473d443f62d253602696c (diff) |
swaybar: implement tray config
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r-- | sway/ipc-json.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 96701dc2..53e0e335 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -1,6 +1,7 @@ #include <json-c/json.h> #include <stdio.h> #include <ctype.h> +#include "config.h" #include "log.h" #include "sway/config.h" #include "sway/ipc-json.h" @@ -785,5 +786,41 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) { } json_object_object_add(json, "outputs", outputs); } +#if HAVE_TRAY + // Add tray outputs if defined + if (bar->tray_outputs && bar->tray_outputs->length > 0) { + json_object *tray_outputs = json_object_new_array(); + for (int i = 0; i < bar->tray_outputs->length; ++i) { + const char *name = bar->tray_outputs->items[i]; + json_object_array_add(tray_outputs, json_object_new_string(name)); + } + json_object_object_add(json, "tray_outputs", tray_outputs); + } + + json_object *tray_bindings = json_object_new_array(); + for (int i = 0; i < 10; ++i) { + if (bar->tray_bindings[i]) { + json_object *bind = json_object_new_object(); + json_object_object_add(bind, "input_code", + json_object_new_int(i)); + json_object_object_add(bind, "command", + json_object_new_string(bar->tray_bindings[i])); + json_object_array_add(tray_bindings, bind); + } + } + if (json_object_array_length(tray_bindings) > 0) { + json_object_object_add(json, "tray_bindings", tray_bindings); + } else { + json_object_put(tray_bindings); + } + + if (bar->icon_theme) { + json_object_object_add(json, "icon_theme", + json_object_new_string(bar->icon_theme)); + } + + json_object_object_add(json, "tray_padding", + json_object_new_int(bar->tray_padding)); +#endif return json; } |