diff options
Diffstat (limited to 'swaymsg')
-rw-r--r-- | swaymsg/main.c | 37 | ||||
-rw-r--r-- | swaymsg/swaymsg.1.txt | 3 |
2 files changed, 39 insertions, 1 deletions
diff --git a/swaymsg/main.c b/swaymsg/main.c index 7e3622d9..89af7345 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c | |||
@@ -106,6 +106,35 @@ static void pretty_print_input(json_object *i) { | |||
106 | json_object_get_int(vendor)); | 106 | json_object_get_int(vendor)); |
107 | } | 107 | } |
108 | 108 | ||
109 | static void pretty_print_seat(json_object *i) { | ||
110 | json_object *name, *capabilities, *devices; | ||
111 | json_object_object_get_ex(i, "name", &name); | ||
112 | json_object_object_get_ex(i, "capabilities", &capabilities); | ||
113 | json_object_object_get_ex(i, "devices", &devices); | ||
114 | |||
115 | const char *fmt = | ||
116 | "Seat: %s\n" | ||
117 | " Capabilities: %d\n"; | ||
118 | |||
119 | printf(fmt, json_object_get_string(name), | ||
120 | json_object_get_int(capabilities)); | ||
121 | |||
122 | size_t devices_len = json_object_array_length(devices); | ||
123 | if (devices_len > 0) { | ||
124 | printf(" Devices:\n"); | ||
125 | for (size_t i = 0; i < devices_len; ++i) { | ||
126 | json_object *device = json_object_array_get_idx(devices, i); | ||
127 | |||
128 | json_object *device_name; | ||
129 | json_object_object_get_ex(device, "name", &device_name); | ||
130 | |||
131 | printf(" %s\n", json_object_get_string(device_name)); | ||
132 | } | ||
133 | } | ||
134 | |||
135 | printf("\n"); | ||
136 | } | ||
137 | |||
109 | static void pretty_print_output(json_object *o) { | 138 | static void pretty_print_output(json_object *o) { |
110 | json_object *name, *rect, *focused, *active, *ws; | 139 | json_object *name, *rect, *focused, *active, *ws; |
111 | json_object_object_get_ex(o, "name", &name); | 140 | json_object_object_get_ex(o, "name", &name); |
@@ -211,7 +240,8 @@ static void pretty_print_clipboard(json_object *v) { | |||
211 | static void pretty_print(int type, json_object *resp) { | 240 | static void pretty_print(int type, json_object *resp) { |
212 | if (type != IPC_COMMAND && type != IPC_GET_WORKSPACES && | 241 | if (type != IPC_COMMAND && type != IPC_GET_WORKSPACES && |
213 | type != IPC_GET_INPUTS && type != IPC_GET_OUTPUTS && | 242 | type != IPC_GET_INPUTS && type != IPC_GET_OUTPUTS && |
214 | type != IPC_GET_VERSION && type != IPC_GET_CLIPBOARD) { | 243 | type != IPC_GET_VERSION && type != IPC_GET_CLIPBOARD && |
244 | type != IPC_GET_SEATS) { | ||
215 | printf("%s\n", json_object_to_json_string_ext(resp, | 245 | printf("%s\n", json_object_to_json_string_ext(resp, |
216 | JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED)); | 246 | JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED)); |
217 | return; | 247 | return; |
@@ -244,6 +274,9 @@ static void pretty_print(int type, json_object *resp) { | |||
244 | case IPC_GET_OUTPUTS: | 274 | case IPC_GET_OUTPUTS: |
245 | pretty_print_output(obj); | 275 | pretty_print_output(obj); |
246 | break; | 276 | break; |
277 | case IPC_GET_SEATS: | ||
278 | pretty_print_seat(obj); | ||
279 | break; | ||
247 | } | 280 | } |
248 | } | 281 | } |
249 | } | 282 | } |
@@ -324,6 +357,8 @@ int main(int argc, char **argv) { | |||
324 | type = IPC_COMMAND; | 357 | type = IPC_COMMAND; |
325 | } else if (strcasecmp(cmdtype, "get_workspaces") == 0) { | 358 | } else if (strcasecmp(cmdtype, "get_workspaces") == 0) { |
326 | type = IPC_GET_WORKSPACES; | 359 | type = IPC_GET_WORKSPACES; |
360 | } else if (strcasecmp(cmdtype, "get_seats") == 0) { | ||
361 | type = IPC_GET_SEATS; | ||
327 | } else if (strcasecmp(cmdtype, "get_inputs") == 0) { | 362 | } else if (strcasecmp(cmdtype, "get_inputs") == 0) { |
328 | type = IPC_GET_INPUTS; | 363 | type = IPC_GET_INPUTS; |
329 | } else if (strcasecmp(cmdtype, "get_outputs") == 0) { | 364 | } else if (strcasecmp(cmdtype, "get_outputs") == 0) { |
diff --git a/swaymsg/swaymsg.1.txt b/swaymsg/swaymsg.1.txt index abc517c8..52209b12 100644 --- a/swaymsg/swaymsg.1.txt +++ b/swaymsg/swaymsg.1.txt | |||
@@ -48,6 +48,9 @@ IPC Message Types | |||
48 | *get_workspaces*:: | 48 | *get_workspaces*:: |
49 | Gets a JSON-encoded list of workspaces and their status. | 49 | Gets a JSON-encoded list of workspaces and their status. |
50 | 50 | ||
51 | *get_seats*:: | ||
52 | Gets a JSON-encoded list of current seats. | ||
53 | |||
51 | *get_inputs*:: | 54 | *get_inputs*:: |
52 | Gets a JSON-encoded list of current inputs. | 55 | Gets a JSON-encoded list of current inputs. |
53 | 56 | ||