aboutsummaryrefslogtreecommitdiff
path: root/sway/ipc-json.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-12-31 15:43:23 -0500
committerGitHub <noreply@github.com>2018-12-31 15:43:23 -0500
commit3d7c20f062bebe39199d3872e5b64d5e8d61d100 (patch)
tree93b8ddb51873cae14db8d5f07db74ca96236f184 /sway/ipc-json.c
parent4a3ada303b948ce2bdf21c7e6254005c85b000ea (diff)
parent9e31f5d79ce9de8f1c73013b792aa94f355a1983 (diff)
Merge pull request #3249 from ianyfan/tray
Swaybar tray
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r--sway/ipc-json.c37
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;
}