diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 4 | ||||
-rw-r--r-- | sway/ipc-server.c | 12 |
2 files changed, 16 insertions, 0 deletions
diff --git a/sway/commands.c b/sway/commands.c index 6c24395f..38019be5 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -602,6 +602,10 @@ static struct cmd_results *cmd_mode(int argc, char **argv) { free(mode_name); // Set current mode config->current_mode = mode; + if (!mode_make) { + // trigger IPC mode event + ipc_event_mode(config->current_mode->name); + } return cmd_results_new(mode_make ? CMD_BLOCK_MODE : CMD_SUCCESS, NULL, NULL); } diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 2bb25202..ed3977d5 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -293,6 +293,8 @@ void ipc_client_handle_command(struct ipc_client *client) { client->subscribed_events |= IPC_EVENT_WORKSPACE; } else if (strcmp(event_type, "barconfig_update") == 0) { client->subscribed_events |= IPC_EVENT_BARCONFIG_UPDATE; + } else if (strcmp(event_type, "mode") == 0) { + client->subscribed_events |= IPC_EVENT_MODE; } else { ipc_send_reply(client, "{\"success\": false}", 18); ipc_client_disconnect(client); @@ -605,3 +607,13 @@ void ipc_event_barconfig_update(struct bar_config *bar) { json_object_put(json); // free } + +void ipc_event_mode(const char *mode) { + json_object *obj = json_object_new_object(); + json_object_object_add(obj, "change", json_object_new_string(mode)); + + const char *json_string = json_object_to_json_string(obj); + ipc_send_event(json_string, IPC_EVENT_MODE); + + json_object_put(obj); // free +} |