summaryrefslogtreecommitdiffstats
path: root/swaybar/ipc.c
diff options
context:
space:
mode:
authorLibravatar Calvin Lee <cyrus296@gmail.com>2017-06-07 16:45:28 -0700
committerLibravatar Calvin Lee <cyrus296@gmail.com>2017-06-07 17:49:16 -0700
commit843ad38b3c427adb0bf319e9613d9813c8d9246c (patch)
treee02a5b06e2b6923371fd53724791c147c18a1fa4 /swaybar/ipc.c
parentMerge pull request #1232 from johalun/master-freebsd (diff)
downloadsway-843ad38b3c427adb0bf319e9613d9813c8d9246c.tar.gz
sway-843ad38b3c427adb0bf319e9613d9813c8d9246c.tar.zst
sway-843ad38b3c427adb0bf319e9613d9813c8d9246c.zip
Implement Tray Icons
This commit implements the StatusNotifierItem protocol, and enables swaybar to show tray icons. It also uses `xembedsniproxy` in order to communicate with xembed applications. The tray is completely optional, and can be disabled on compile time with the `enable-tray` option. Or on runtime with the bar config option `tray_output none`. Overview of changes: In swaybar very little is changed outside the tray subfolder except that all events are now polled in `event_loop.c`, this creates no functional difference. Six bar configuration options were added, these are detailed in sway-bar(5) The tray subfolder is where all protocol implementation takes place and is organised as follows: tray/sni_watcher.c: This file contains the StatusNotifierWatcher. It keeps track of items and hosts and reports when they come or go. tray/tray.c This file contains the StatusNotifierHost. It keeps track of sway's version of the items and represents the tray itself. tray/sni.c This file contains the StatusNotifierItem struct and all communication with individual items. tray/icon.c This file implements the icon theme protocol. It allows for finding icons by name, rather than by pixmap. tray/dbus.c This file allows for asynchronous DBus communication. See #986 #343
Diffstat (limited to 'swaybar/ipc.c')
-rw-r--r--swaybar/ipc.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/swaybar/ipc.c b/swaybar/ipc.c
index b08eeea8..93d1219c 100644
--- a/swaybar/ipc.c
+++ b/swaybar/ipc.c
@@ -19,11 +19,19 @@ void ipc_send_workspace_command(const char *workspace_name) {
19 19
20static void ipc_parse_config(struct config *config, const char *payload) { 20static void ipc_parse_config(struct config *config, const char *payload) {
21 json_object *bar_config = json_tokener_parse(payload); 21 json_object *bar_config = json_tokener_parse(payload);
22 json_object *tray_output, *mode, *hidden_bar, *position, *status_command; 22 json_object *markup, *mode, *hidden_bar, *position, *status_command;
23 json_object *font, *bar_height, *wrap_scroll, *workspace_buttons, *strip_workspace_numbers; 23 json_object *font, *bar_height, *wrap_scroll, *workspace_buttons, *strip_workspace_numbers;
24 json_object *binding_mode_indicator, *verbose, *colors, *sep_symbol, *outputs; 24 json_object *binding_mode_indicator, *verbose, *colors, *sep_symbol, *outputs;
25 json_object *markup; 25#ifdef ENABLE_TRAY
26 json_object *tray_output, *icon_theme, *tray_padding, *activate_button, *context_button;
27 json_object *secondary_button;
26 json_object_object_get_ex(bar_config, "tray_output", &tray_output); 28 json_object_object_get_ex(bar_config, "tray_output", &tray_output);
29 json_object_object_get_ex(bar_config, "icon_theme", &icon_theme);
30 json_object_object_get_ex(bar_config, "tray_padding", &tray_padding);
31 json_object_object_get_ex(bar_config, "activate_button", &activate_button);
32 json_object_object_get_ex(bar_config, "context_button", &context_button);
33 json_object_object_get_ex(bar_config, "secondary_button", &secondary_button);
34#endif
27 json_object_object_get_ex(bar_config, "mode", &mode); 35 json_object_object_get_ex(bar_config, "mode", &mode);
28 json_object_object_get_ex(bar_config, "hidden_bar", &hidden_bar); 36 json_object_object_get_ex(bar_config, "hidden_bar", &hidden_bar);
29 json_object_object_get_ex(bar_config, "position", &position); 37 json_object_object_get_ex(bar_config, "position", &position);
@@ -83,6 +91,34 @@ static void ipc_parse_config(struct config *config, const char *payload) {
83 config->pango_markup = json_object_get_boolean(markup); 91 config->pango_markup = json_object_get_boolean(markup);
84 } 92 }
85 93
94#ifdef ENABLE_TRAY
95 if (tray_output) {
96 free(config->tray_output);
97 config->tray_output = strdup(json_object_get_string(tray_output));
98 }
99
100 if (icon_theme) {
101 free(config->icon_theme);
102 config->icon_theme = strdup(json_object_get_string(icon_theme));
103 }
104
105 if (tray_padding) {
106 config->tray_padding = json_object_get_int(tray_padding);
107 }
108
109 if (activate_button) {
110 config->activate_button = json_object_get_int(activate_button);
111 }
112
113 if (context_button) {
114 config->context_button = json_object_get_int(context_button);
115 }
116
117 if (secondary_button) {
118 config->secondary_button = json_object_get_int(secondary_button);
119 }
120#endif
121
86 // free previous outputs list 122 // free previous outputs list
87 int i; 123 int i;
88 for (i = 0; i < config->outputs->length; ++i) { 124 for (i = 0; i < config->outputs->length; ++i) {