diff options
-rw-r--r-- | completions/bash/swaymsg | 1 | ||||
-rw-r--r-- | completions/fish/swaymsg.fish | 1 | ||||
-rw-r--r-- | completions/zsh/_swaymsg | 1 | ||||
-rw-r--r-- | include/ipc.h | 1 | ||||
-rw-r--r-- | include/sway/ipc-json.h | 2 | ||||
-rw-r--r-- | sway/ipc-json.c | 7 | ||||
-rw-r--r-- | sway/ipc-server.c | 10 | ||||
-rw-r--r-- | sway/sway-ipc.7.scd | 20 | ||||
-rw-r--r-- | swaymsg/main.c | 2 | ||||
-rw-r--r-- | swaymsg/swaymsg.1.scd | 3 |
10 files changed, 48 insertions, 0 deletions
diff --git a/completions/bash/swaymsg b/completions/bash/swaymsg index 1211787d..f865e4e1 100644 --- a/completions/bash/swaymsg +++ b/completions/bash/swaymsg | |||
@@ -15,6 +15,7 @@ _swaymsg() | |||
15 | 'get_bar_config' | 15 | 'get_bar_config' |
16 | 'get_version' | 16 | 'get_version' |
17 | 'get_binding_modes' | 17 | 'get_binding_modes' |
18 | 'get_binding_state' | ||
18 | 'get_config' | 19 | 'get_config' |
19 | 'send_tick' | 20 | 'send_tick' |
20 | 'subscribe' | 21 | 'subscribe' |
diff --git a/completions/fish/swaymsg.fish b/completions/fish/swaymsg.fish index 25085f9a..5ee7dcc0 100644 --- a/completions/fish/swaymsg.fish +++ b/completions/fish/swaymsg.fish | |||
@@ -18,6 +18,7 @@ complete -c swaymsg -s t -l type -fra 'get_marks' --description "Get a JSON-enco | |||
18 | complete -c swaymsg -s t -l type -fra 'get_bar_config' --description "Get a JSON-encoded configuration for swaybar." | 18 | complete -c swaymsg -s t -l type -fra 'get_bar_config' --description "Get a JSON-encoded configuration for swaybar." |
19 | complete -c swaymsg -s t -l type -fra 'get_version' --description "Get JSON-encoded version information for the running instance of sway." | 19 | complete -c swaymsg -s t -l type -fra 'get_version' --description "Get JSON-encoded version information for the running instance of sway." |
20 | complete -c swaymsg -s t -l type -fra 'get_binding_modes' --description "Gets a JSON-encoded list of currently configured binding modes." | 20 | complete -c swaymsg -s t -l type -fra 'get_binding_modes' --description "Gets a JSON-encoded list of currently configured binding modes." |
21 | complete -c swaymsg -s t -l type -fra 'get_binding_state' --description "Get JSON-encoded info about the current binding state." | ||
21 | complete -c swaymsg -s t -l type -fra 'get_config' --description "Gets a JSON-encoded copy of the current configuration." | 22 | complete -c swaymsg -s t -l type -fra 'get_config' --description "Gets a JSON-encoded copy of the current configuration." |
22 | complete -c swaymsg -s t -l type -fra 'get_seats' --description "Gets a JSON-encoded list of all seats, its properties and all assigned devices." | 23 | complete -c swaymsg -s t -l type -fra 'get_seats' --description "Gets a JSON-encoded list of all seats, its properties and all assigned devices." |
23 | complete -c swaymsg -s t -l type -fra 'send_tick' --description "Sends a tick event to all subscribed clients." | 24 | complete -c swaymsg -s t -l type -fra 'send_tick' --description "Sends a tick event to all subscribed clients." |
diff --git a/completions/zsh/_swaymsg b/completions/zsh/_swaymsg index 3f42a77d..106f3d9d 100644 --- a/completions/zsh/_swaymsg +++ b/completions/zsh/_swaymsg | |||
@@ -23,6 +23,7 @@ types=( | |||
23 | 'get_bar_config' | 23 | 'get_bar_config' |
24 | 'get_version' | 24 | 'get_version' |
25 | 'get_binding_modes' | 25 | 'get_binding_modes' |
26 | 'get_binding_state' | ||
26 | 'get_config' | 27 | 'get_config' |
27 | 'send_tick' | 28 | 'send_tick' |
28 | 'subscribe' | 29 | 'subscribe' |
diff --git a/include/ipc.h b/include/ipc.h index 7ae21ab3..ff011750 100644 --- a/include/ipc.h +++ b/include/ipc.h | |||
@@ -17,6 +17,7 @@ enum ipc_command_type { | |||
17 | IPC_GET_CONFIG = 9, | 17 | IPC_GET_CONFIG = 9, |
18 | IPC_SEND_TICK = 10, | 18 | IPC_SEND_TICK = 10, |
19 | IPC_SYNC = 11, | 19 | IPC_SYNC = 11, |
20 | IPC_GET_BINDING_STATE = 12, | ||
20 | 21 | ||
21 | // sway-specific command types | 22 | // sway-specific command types |
22 | IPC_GET_INPUTS = 100, | 23 | IPC_GET_INPUTS = 100, |
diff --git a/include/sway/ipc-json.h b/include/sway/ipc-json.h index 3e584dbb..6f4ade1a 100644 --- a/include/sway/ipc-json.h +++ b/include/sway/ipc-json.h | |||
@@ -6,6 +6,8 @@ | |||
6 | 6 | ||
7 | json_object *ipc_json_get_version(void); | 7 | json_object *ipc_json_get_version(void); |
8 | 8 | ||
9 | json_object *ipc_json_get_binding_mode(void); | ||
10 | |||
9 | json_object *ipc_json_describe_disabled_output(struct sway_output *o); | 11 | json_object *ipc_json_describe_disabled_output(struct sway_output *o); |
10 | json_object *ipc_json_describe_node(struct sway_node *node); | 12 | json_object *ipc_json_describe_node(struct sway_node *node); |
11 | json_object *ipc_json_describe_node_recursive(struct sway_node *node); | 13 | json_object *ipc_json_describe_node_recursive(struct sway_node *node); |
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) { | |||
1261 | #endif | 1261 | #endif |
1262 | return json; | 1262 | return json; |
1263 | } | 1263 | } |
1264 | |||
1265 | json_object *ipc_json_get_binding_mode(void) { | ||
1266 | json_object *current_mode = json_object_new_object(); | ||
1267 | json_object_object_add(current_mode, "name", | ||
1268 | json_object_new_string(config->current_mode->name)); | ||
1269 | return current_mode; | ||
1270 | } | ||
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 | |||
876 | goto exit_cleanup; | 876 | goto exit_cleanup; |
877 | } | 877 | } |
878 | 878 | ||
879 | case IPC_GET_BINDING_STATE: | ||
880 | { | ||
881 | json_object *current_mode = ipc_json_get_binding_mode(); | ||
882 | const char *json_string = json_object_to_json_string(current_mode); | ||
883 | ipc_send_reply(client, payload_type, json_string, | ||
884 | (uint32_t)strlen(json_string)); | ||
885 | json_object_put(current_mode); // free | ||
886 | goto exit_cleanup; | ||
887 | } | ||
888 | |||
879 | case IPC_GET_CONFIG: | 889 | case IPC_GET_CONFIG: |
880 | { | 890 | { |
881 | json_object *json = json_object_new_object(); | 891 | 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.* | |||
75 | |- 11 | 75 | |- 11 |
76 | : SYNC | 76 | : SYNC |
77 | : Replies failure object for i3 compatibility | 77 | : Replies failure object for i3 compatibility |
78 | |- 12 | ||
79 | : GET_BINDING_STATE | ||
80 | : Request the current binding state, e.g. the currently active binding mode name. | ||
78 | |- 100 | 81 | |- 100 |
79 | : GET_INPUTS | 82 | : GET_INPUTS |
80 | : Get the list of input devices | 83 | : Get the list of input devices |
@@ -1067,6 +1070,23 @@ boolean value _false_. | |||
1067 | } | 1070 | } |
1068 | ``` | 1071 | ``` |
1069 | 1072 | ||
1073 | ## 12. GET_BINDING_STATE | ||
1074 | |||
1075 | *MESSAGE*++ | ||
1076 | Returns the currently active binding mode. | ||
1077 | |||
1078 | *REPLY*++ | ||
1079 | A single object that contains the property _name_, which is set to the | ||
1080 | currently active binding mode as a string. | ||
1081 | |||
1082 | *Exact Reply:* | ||
1083 | ``` | ||
1084 | { | ||
1085 | "name": "default" | ||
1086 | } | ||
1087 | ``` | ||
1088 | |||
1089 | |||
1070 | ## 100. GET_INPUTS | 1090 | ## 100. GET_INPUTS |
1071 | 1091 | ||
1072 | *MESSAGE*++ | 1092 | *MESSAGE*++ |
diff --git a/swaymsg/main.c b/swaymsg/main.c index f9d3515a..38976f9c 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c | |||
@@ -440,6 +440,8 @@ int main(int argc, char **argv) { | |||
440 | type = IPC_GET_VERSION; | 440 | type = IPC_GET_VERSION; |
441 | } else if (strcasecmp(cmdtype, "get_binding_modes") == 0) { | 441 | } else if (strcasecmp(cmdtype, "get_binding_modes") == 0) { |
442 | type = IPC_GET_BINDING_MODES; | 442 | type = IPC_GET_BINDING_MODES; |
443 | } else if (strcasecmp(cmdtype, "get_binding_state") == 0) { | ||
444 | type = IPC_GET_BINDING_STATE; | ||
443 | } else if (strcasecmp(cmdtype, "get_config") == 0) { | 445 | } else if (strcasecmp(cmdtype, "get_config") == 0) { |
444 | type = IPC_GET_CONFIG; | 446 | type = IPC_GET_CONFIG; |
445 | } else if (strcasecmp(cmdtype, "send_tick") == 0) { | 447 | } else if (strcasecmp(cmdtype, "send_tick") == 0) { |
diff --git a/swaymsg/swaymsg.1.scd b/swaymsg/swaymsg.1.scd index 515d745f..b8a38b54 100644 --- a/swaymsg/swaymsg.1.scd +++ b/swaymsg/swaymsg.1.scd | |||
@@ -80,6 +80,9 @@ _swaymsg_ [options...] [message] | |||
80 | *get\_binding\_modes* | 80 | *get\_binding\_modes* |
81 | Gets a JSON-encoded list of currently configured binding modes. | 81 | Gets a JSON-encoded list of currently configured binding modes. |
82 | 82 | ||
83 | *get\_binding\_state* | ||
84 | Gets JSON-encoded info about the current binding state. | ||
85 | |||
83 | *get\_config* | 86 | *get\_config* |
84 | Gets a JSON-encoded copy of the current configuration. | 87 | Gets a JSON-encoded copy of the current configuration. |
85 | 88 | ||