diff options
author | Ian Fan <ianfan0@gmail.com> | 2018-12-09 15:10:41 +0000 |
---|---|---|
committer | Ian Fan <ianfan0@gmail.com> | 2018-12-31 20:40:18 +0000 |
commit | 6b03c68775c9c638def342c82b1fa3beffa52645 (patch) | |
tree | a3b18d948f8e2a51151f24aab47c552f28a17f70 /swaybar | |
parent | 74655f835aa9fe0e976473d443f62d253602696c (diff) |
swaybar: implement tray config
Diffstat (limited to 'swaybar')
-rw-r--r-- | swaybar/bar.c | 1 | ||||
-rw-r--r-- | swaybar/config.c | 12 | ||||
-rw-r--r-- | swaybar/ipc.c | 34 |
3 files changed, 47 insertions, 0 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index c26e76ce..668168eb 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -11,6 +11,7 @@ #include <wayland-client.h> #include <wayland-cursor.h> #include <wlr/util/log.h> +#include "config.h" #include "swaybar/bar.h" #include "swaybar/config.h" #include "swaybar/i3bar.h" diff --git a/swaybar/config.c b/swaybar/config.c index 10c78c8a..9cafe061 100644 --- a/swaybar/config.c +++ b/swaybar/config.c @@ -4,6 +4,7 @@ #include <wlr/util/log.h> #include "swaybar/config.h" #include "wlr-layer-shell-unstable-v1-client-protocol.h" +#include "config.h" #include "stringop.h" #include "list.h" @@ -73,6 +74,10 @@ struct swaybar_config *init_config(void) { config->colors.binding_mode.background = 0x900000FF; config->colors.binding_mode.text = 0xFFFFFFFF; +#if HAVE_TRAY + config->tray_padding = 2; +#endif + return config; } @@ -102,5 +107,12 @@ void free_config(struct swaybar_config *config) { free(coutput->name); free(coutput); } +#if HAVE_TRAY + list_free_items_and_destroy(config->tray_outputs); + for (int i = 0; i < 10; ++i) { + free(config->tray_bindings[i]); + } + free(config->icon_theme); +#endif free(config); } diff --git a/swaybar/ipc.c b/swaybar/ipc.c index 2b930786..df0586bf 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c @@ -6,6 +6,7 @@ #include <wlr/util/log.h> #include "swaybar/config.h" #include "swaybar/ipc.h" +#include "config.h" #include "ipc-client.h" #include "list.h" @@ -282,6 +283,39 @@ static bool ipc_parse_config( ipc_parse_colors(config, colors); } +#if HAVE_TRAY + json_object *tray_outputs, *tray_padding, *tray_bindings, *icon_theme; + + if ((json_object_object_get_ex(bar_config, "tray_outputs", &tray_outputs))) { + config->tray_outputs = create_list(); + int length = json_object_array_length(tray_outputs); + for (int i = 0; i < length; ++i) { + json_object *o = json_object_array_get_idx(tray_outputs, i); + list_add(config->tray_outputs, strdup(json_object_get_string(o))); + } + } + + if ((json_object_object_get_ex(bar_config, "tray_padding", &tray_padding))) { + config->tray_padding = json_object_get_int(tray_padding); + } + + if ((json_object_object_get_ex(bar_config, "tray_bindings", &tray_bindings))) { + int length = json_object_array_length(tray_bindings); + for (int i = 0; i < length; ++i) { + json_object *bind = json_object_array_get_idx(tray_bindings, i); + json_object *button, *command; + json_object_object_get_ex(bind, "input_code", &button); + json_object_object_get_ex(bind, "command", &command); + config->tray_bindings[json_object_get_int(button)] = + strdup(json_object_get_string(command)); + } + } + + if ((json_object_object_get_ex(bar_config, "icon_theme", &icon_theme))) { + config->icon_theme = strdup(json_object_get_string(icon_theme)); + } +#endif + json_object_put(bar_config); return true; } |