This type dumps all currently configured binding modes.
fixes #2375
GET_VERSION (7)::
Gets the version of i3. The reply will be a JSON-encoded dictionary
with the major, minor, patch and human-readable version.
+GET_BINDING_MODES (8)::
+ Gets a list of currently configured binding modes.
So, a typical message could look like this:
--------------------------------------------------
Reply to the GET_BAR_CONFIG message.
VERSION (7)::
Reply to the GET_VERSION message.
+BINDING_MODES (8)::
+ Reply to the GET_BINDING_MODES message.
=== COMMAND reply
}
-------------------
+=== BINDING_MODES reply
+
+The reply consists of an array of all currently configured binding modes.
+
+*Example:*
+---------------------
+["default", "resize"]
+---------------------
+
== Events
[[events]]
message_type = I3_IPC_MESSAGE_TYPE_GET_MARKS;
else if (strcasecmp(optarg, "get_bar_config") == 0)
message_type = I3_IPC_MESSAGE_TYPE_GET_BAR_CONFIG;
+ else if (strcasecmp(optarg, "get_binding_modes") == 0)
+ message_type = I3_IPC_MESSAGE_TYPE_GET_BINDING_MODES;
else if (strcasecmp(optarg, "get_version") == 0)
message_type = I3_IPC_MESSAGE_TYPE_GET_VERSION;
else {
printf("Unknown message type\n");
- printf("Known types: command, get_workspaces, get_outputs, get_tree, get_marks, get_bar_config, get_version\n");
+ printf("Known types: command, get_workspaces, get_outputs, get_tree, get_marks, get_bar_config, get_binding_modes, get_version\n");
exit(EXIT_FAILURE);
}
} else if (o == 'q') {
/** Request the i3 version */
#define I3_IPC_MESSAGE_TYPE_GET_VERSION 7
+/** Request a list of configured binding modes. */
+#define I3_IPC_MESSAGE_TYPE_GET_BINDING_MODES 8
+
/*
* Messages from i3 to clients
*
*/
-
-/** Command reply type */
#define I3_IPC_REPLY_TYPE_COMMAND 0
-
-/** Workspaces reply type */
#define I3_IPC_REPLY_TYPE_WORKSPACES 1
-
-/** Subscription reply type */
#define I3_IPC_REPLY_TYPE_SUBSCRIBE 2
-
-/** Outputs reply type */
#define I3_IPC_REPLY_TYPE_OUTPUTS 3
-
-/** Tree reply type */
#define I3_IPC_REPLY_TYPE_TREE 4
-
-/** Marks reply type */
#define I3_IPC_REPLY_TYPE_MARKS 5
-
-/** Bar config reply type */
#define I3_IPC_REPLY_TYPE_BAR_CONFIG 6
-
-/** i3 version reply type */
#define I3_IPC_REPLY_TYPE_VERSION 7
+#define I3_IPC_REPLY_TYPE_BINDING_MODES 8
/*
* Events from i3 to clients. Events have the first bit set high.
Gets the configuration (as JSON map) of the workspace bar with the given ID. If
no ID is provided, an array with all configured bar IDs is returned instead.
+get_binding_modes::
+Gets a list of configured binding modes.
+
get_version::
Gets the version of i3. The reply will be a JSON-encoded dictionary with the
major, minor, patch and human-readable version.
y(free);
}
+/*
+ * Returns a list of configured binding modes
+ *
+ */
+IPC_HANDLER(get_binding_modes) {
+ yajl_gen gen = ygenalloc();
+
+ y(array_open);
+ struct Mode *mode;
+ SLIST_FOREACH(mode, &modes, modes) {
+ ystr(mode->name);
+ }
+ y(array_close);
+
+ const unsigned char *payload;
+ ylength length;
+ y(get_buf, &payload, &length);
+
+ ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_BINDING_MODES, payload);
+ y(free);
+}
+
/*
* Callback for the YAJL parser (will be called when a string is parsed).
*
/* The index of each callback function corresponds to the numeric
* value of the message type (see include/i3/ipc.h) */
-handler_t handlers[8] = {
+handler_t handlers[9] = {
handle_command,
handle_get_workspaces,
handle_subscribe,
handle_get_marks,
handle_get_bar_config,
handle_get_version,
+ handle_get_binding_modes,
};
/*