commit 5fd36164a008f931def993413facf9058c56641d
parent c1bb73f8652f367ee7b7b82f5fc13aff51145358
Author: Ian Fan <ianfan0@gmail.com>
Date: Sun, 8 Jul 2018 20:32:42 +0100
Add get_binding_modes message type to ipc
Diffstat:
4 files changed, 20 insertions(+), 0 deletions(-)
diff --git 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
@@ -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
@@ -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
@@ -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