summaryrefslogtreecommitdiffstats
path: root/sway/ipc-json.c
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2018-12-09 15:10:41 +0000
committerLibravatar Ian Fan <ianfan0@gmail.com>2018-12-31 20:40:18 +0000
commit6b03c68775c9c638def342c82b1fa3beffa52645 (patch)
treea3b18d948f8e2a51151f24aab47c552f28a17f70 /sway/ipc-json.c
parentswaybar: add StatusNotifierItem to tray (diff)
downloadsway-6b03c68775c9c638def342c82b1fa3beffa52645.tar.gz
sway-6b03c68775c9c638def342c82b1fa3beffa52645.tar.zst
sway-6b03c68775c9c638def342c82b1fa3beffa52645.zip
swaybar: implement tray config
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 @@
1#include <json-c/json.h> 1#include <json-c/json.h>
2#include <stdio.h> 2#include <stdio.h>
3#include <ctype.h> 3#include <ctype.h>
4#include "config.h"
4#include "log.h" 5#include "log.h"
5#include "sway/config.h" 6#include "sway/config.h"
6#include "sway/ipc-json.h" 7#include "sway/ipc-json.h"
@@ -785,5 +786,41 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
785 } 786 }
786 json_object_object_add(json, "outputs", outputs); 787 json_object_object_add(json, "outputs", outputs);
787 } 788 }
789#if HAVE_TRAY
790 // Add tray outputs if defined
791 if (bar->tray_outputs && bar->tray_outputs->length > 0) {
792 json_object *tray_outputs = json_object_new_array();
793 for (int i = 0; i < bar->tray_outputs->length; ++i) {
794 const char *name = bar->tray_outputs->items[i];
795 json_object_array_add(tray_outputs, json_object_new_string(name));
796 }
797 json_object_object_add(json, "tray_outputs", tray_outputs);
798 }
799
800 json_object *tray_bindings = json_object_new_array();
801 for (int i = 0; i < 10; ++i) {
802 if (bar->tray_bindings[i]) {
803 json_object *bind = json_object_new_object();
804 json_object_object_add(bind, "input_code",
805 json_object_new_int(i));
806 json_object_object_add(bind, "command",
807 json_object_new_string(bar->tray_bindings[i]));
808 json_object_array_add(tray_bindings, bind);
809 }
810 }
811 if (json_object_array_length(tray_bindings) > 0) {
812 json_object_object_add(json, "tray_bindings", tray_bindings);
813 } else {
814 json_object_put(tray_bindings);
815 }
816
817 if (bar->icon_theme) {
818 json_object_object_add(json, "icon_theme",
819 json_object_new_string(bar->icon_theme));
820 }
821
822 json_object_object_add(json, "tray_padding",
823 json_object_new_int(bar->tray_padding));
824#endif
788 return json; 825 return json;
789} 826}