mirror of
https://github.com/swaywm/sway.git
synced 2024-11-12 21:43:59 +01:00
i3-compat: add GET_BINDING_STATE IPC command
This commit is contained in:
parent
f9361ae36c
commit
45859be03f
@ -15,6 +15,7 @@ _swaymsg()
|
|||||||
'get_bar_config'
|
'get_bar_config'
|
||||||
'get_version'
|
'get_version'
|
||||||
'get_binding_modes'
|
'get_binding_modes'
|
||||||
|
'get_binding_state'
|
||||||
'get_config'
|
'get_config'
|
||||||
'send_tick'
|
'send_tick'
|
||||||
'subscribe'
|
'subscribe'
|
||||||
|
@ -18,6 +18,7 @@ complete -c swaymsg -s t -l type -fra 'get_marks' --description "Get a JSON-enco
|
|||||||
complete -c swaymsg -s t -l type -fra 'get_bar_config' --description "Get a JSON-encoded configuration for swaybar."
|
complete -c swaymsg -s t -l type -fra 'get_bar_config' --description "Get a JSON-encoded configuration for swaybar."
|
||||||
complete -c swaymsg -s t -l type -fra 'get_version' --description "Get JSON-encoded version information for the running instance of sway."
|
complete -c swaymsg -s t -l type -fra 'get_version' --description "Get JSON-encoded version information for the running instance of sway."
|
||||||
complete -c swaymsg -s t -l type -fra 'get_binding_modes' --description "Gets a JSON-encoded list of currently configured binding modes."
|
complete -c swaymsg -s t -l type -fra 'get_binding_modes' --description "Gets a JSON-encoded list of currently configured binding modes."
|
||||||
|
complete -c swaymsg -s t -l type -fra 'get_binding_state' --description "Get JSON-encoded info about the current binding state."
|
||||||
complete -c swaymsg -s t -l type -fra 'get_config' --description "Gets a JSON-encoded copy of the current configuration."
|
complete -c swaymsg -s t -l type -fra 'get_config' --description "Gets a JSON-encoded copy of the current configuration."
|
||||||
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."
|
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."
|
||||||
complete -c swaymsg -s t -l type -fra 'send_tick' --description "Sends a tick event to all subscribed clients."
|
complete -c swaymsg -s t -l type -fra 'send_tick' --description "Sends a tick event to all subscribed clients."
|
||||||
|
@ -23,6 +23,7 @@ types=(
|
|||||||
'get_bar_config'
|
'get_bar_config'
|
||||||
'get_version'
|
'get_version'
|
||||||
'get_binding_modes'
|
'get_binding_modes'
|
||||||
|
'get_binding_state'
|
||||||
'get_config'
|
'get_config'
|
||||||
'send_tick'
|
'send_tick'
|
||||||
'subscribe'
|
'subscribe'
|
||||||
|
@ -17,6 +17,7 @@ enum ipc_command_type {
|
|||||||
IPC_GET_CONFIG = 9,
|
IPC_GET_CONFIG = 9,
|
||||||
IPC_SEND_TICK = 10,
|
IPC_SEND_TICK = 10,
|
||||||
IPC_SYNC = 11,
|
IPC_SYNC = 11,
|
||||||
|
IPC_GET_BINDING_STATE = 12,
|
||||||
|
|
||||||
// sway-specific command types
|
// sway-specific command types
|
||||||
IPC_GET_INPUTS = 100,
|
IPC_GET_INPUTS = 100,
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
json_object *ipc_json_get_version(void);
|
json_object *ipc_json_get_version(void);
|
||||||
|
|
||||||
|
json_object *ipc_json_get_binding_mode(void);
|
||||||
|
|
||||||
json_object *ipc_json_describe_disabled_output(struct sway_output *o);
|
json_object *ipc_json_describe_disabled_output(struct sway_output *o);
|
||||||
json_object *ipc_json_describe_node(struct sway_node *node);
|
json_object *ipc_json_describe_node(struct sway_node *node);
|
||||||
json_object *ipc_json_describe_node_recursive(struct sway_node *node);
|
json_object *ipc_json_describe_node_recursive(struct sway_node *node);
|
||||||
|
@ -1261,3 +1261,10 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
|
|||||||
#endif
|
#endif
|
||||||
return json;
|
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;
|
||||||
|
}
|
||||||
|
@ -876,6 +876,16 @@ void ipc_client_handle_command(struct ipc_client *client, uint32_t payload_lengt
|
|||||||
goto exit_cleanup;
|
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:
|
case IPC_GET_CONFIG:
|
||||||
{
|
{
|
||||||
json_object *json = json_object_new_object();
|
json_object *json = json_object_new_object();
|
||||||
|
@ -75,6 +75,9 @@ supported. *For all replies, any properties not listed are subject to removal.*
|
|||||||
|- 11
|
|- 11
|
||||||
: SYNC
|
: SYNC
|
||||||
: Replies failure object for i3 compatibility
|
: Replies failure object for i3 compatibility
|
||||||
|
|- 12
|
||||||
|
: GET_BINDING_STATE
|
||||||
|
: Request the current binding state, e.g. the currently active binding mode name.
|
||||||
|- 100
|
|- 100
|
||||||
: GET_INPUTS
|
: GET_INPUTS
|
||||||
: Get the list of input devices
|
: 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
|
## 100. GET_INPUTS
|
||||||
|
|
||||||
*MESSAGE*++
|
*MESSAGE*++
|
||||||
|
@ -440,6 +440,8 @@ int main(int argc, char **argv) {
|
|||||||
type = IPC_GET_VERSION;
|
type = IPC_GET_VERSION;
|
||||||
} else if (strcasecmp(cmdtype, "get_binding_modes") == 0) {
|
} else if (strcasecmp(cmdtype, "get_binding_modes") == 0) {
|
||||||
type = IPC_GET_BINDING_MODES;
|
type = IPC_GET_BINDING_MODES;
|
||||||
|
} else if (strcasecmp(cmdtype, "get_binding_state") == 0) {
|
||||||
|
type = IPC_GET_BINDING_STATE;
|
||||||
} else if (strcasecmp(cmdtype, "get_config") == 0) {
|
} else if (strcasecmp(cmdtype, "get_config") == 0) {
|
||||||
type = IPC_GET_CONFIG;
|
type = IPC_GET_CONFIG;
|
||||||
} else if (strcasecmp(cmdtype, "send_tick") == 0) {
|
} else if (strcasecmp(cmdtype, "send_tick") == 0) {
|
||||||
|
@ -80,6 +80,9 @@ _swaymsg_ [options...] [message]
|
|||||||
*get\_binding\_modes*
|
*get\_binding\_modes*
|
||||||
Gets a JSON-encoded list of currently configured binding modes.
|
Gets a JSON-encoded list of currently configured binding modes.
|
||||||
|
|
||||||
|
*get\_binding\_state*
|
||||||
|
Gets JSON-encoded info about the current binding state.
|
||||||
|
|
||||||
*get\_config*
|
*get\_config*
|
||||||
Gets a JSON-encoded copy of the current configuration.
|
Gets a JSON-encoded copy of the current configuration.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user