diff options
-rw-r--r-- | include/ipc.h | 1 | ||||
-rw-r--r-- | sway/ipc-server.c | 14 | ||||
-rw-r--r-- | swaymsg/main.c | 2 | ||||
-rw-r--r-- | swaymsg/swaymsg.1.scd | 3 |
4 files changed, 20 insertions, 0 deletions
diff --git a/include/ipc.h b/include/ipc.h index 8172c782..c9c5b1cd 100644 --- a/include/ipc.h +++ b/include/ipc.h @@ -13,6 +13,7 @@ enum ipc_command_type { IPC_GET_MARKS = 5, IPC_GET_BAR_CONFIG = 6, IPC_GET_VERSION = 7, + IPC_GET_BINDING_MODES = 8, // sway-specific command types IPC_GET_INPUTS = 100, diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 197851cf..70a4141e 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -667,6 +667,20 @@ void ipc_client_handle_command(struct ipc_client *client) { goto exit_cleanup; } + case IPC_GET_BINDING_MODES: + { + json_object *modes = json_object_new_array(); + for (int i = 0; i < config->modes->length; i++) { + struct sway_mode *mode = config->modes->items[i]; + json_object_array_add(modes, json_object_new_string(mode->name)); + } + const char *json_string = json_object_to_json_string(modes); + client_valid = + ipc_send_reply(client, json_string, (uint32_t)strlen(json_string)); + json_object_put(modes); // free + goto exit_cleanup; + } + default: wlr_log(WLR_INFO, "Unknown IPC command type %i", client->current_command); goto exit_cleanup; diff --git a/swaymsg/main.c b/swaymsg/main.c index 542ca819..42e488f3 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c @@ -407,6 +407,8 @@ int main(int argc, char **argv) { type = IPC_GET_BAR_CONFIG; } else if (strcasecmp(cmdtype, "get_version") == 0) { type = IPC_GET_VERSION; + } else if (strcasecmp(cmdtype, "get_binding_modes") == 0) { + type = IPC_GET_BINDING_MODES; } else if (strcasecmp(cmdtype, "get_clipboard") == 0) { type = IPC_GET_CLIPBOARD; } else { diff --git a/swaymsg/swaymsg.1.scd b/swaymsg/swaymsg.1.scd index 1aa6a1b0..f9b600b9 100644 --- a/swaymsg/swaymsg.1.scd +++ b/swaymsg/swaymsg.1.scd @@ -59,6 +59,9 @@ _swaymsg_ [options...] [message] *get\_version* Get JSON-encoded version information for the running instance of sway. +*get\_binding\_modes* + Gets a JSON-encoded list of currently configured binding modes. + *get\_clipboard* Get JSON-encoded information about the clipboard. Returns the current clipboard mime-types if called without |