aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/ipc-json.c7
-rw-r--r--sway/ipc-server.c10
-rw-r--r--sway/sway-ipc.7.scd20
3 files changed, 37 insertions, 0 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 066fd8db..70b81ad1 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -1261,3 +1261,10 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
#endif
return json;
}
+
+json_object *ipc_json_get_binding_mode(void) {
+ json_object *current_mode = json_object_new_object();
+ json_object_object_add(current_mode, "name",
+ json_object_new_string(config->current_mode->name));
+ return current_mode;
+}
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index bd9f40bc..62bdccb8 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -876,6 +876,16 @@ void ipc_client_handle_command(struct ipc_client *client, uint32_t payload_lengt
goto exit_cleanup;
}
+ case IPC_GET_BINDING_STATE:
+ {
+ json_object *current_mode = ipc_json_get_binding_mode();
+ const char *json_string = json_object_to_json_string(current_mode);
+ ipc_send_reply(client, payload_type, json_string,
+ (uint32_t)strlen(json_string));
+ json_object_put(current_mode); // free
+ goto exit_cleanup;
+ }
+
case IPC_GET_CONFIG:
{
json_object *json = json_object_new_object();
diff --git a/sway/sway-ipc.7.scd b/sway/sway-ipc.7.scd
index 63e3ceb6..495e2e7d 100644
--- a/sway/sway-ipc.7.scd
+++ b/sway/sway-ipc.7.scd
@@ -75,6 +75,9 @@ supported. *For all replies, any properties not listed are subject to removal.*
|- 11
: SYNC
: Replies failure object for i3 compatibility
+|- 12
+: GET_BINDING_STATE
+: Request the current binding state, e.g. the currently active binding mode name.
|- 100
: GET_INPUTS
: Get the list of input devices
@@ -1067,6 +1070,23 @@ boolean value _false_.
}
```
+## 12. GET_BINDING_STATE
+
+*MESSAGE*++
+Returns the currently active binding mode.
+
+*REPLY*++
+A single object that contains the property _name_, which is set to the
+currently active binding mode as a string.
+
+*Exact Reply:*
+```
+{
+ "name": "default"
+}
+```
+
+
## 100. GET_INPUTS
*MESSAGE*++