diff options
author | 2018-05-12 09:00:32 -0400 | |
---|---|---|
committer | 2018-05-12 09:00:32 -0400 | |
commit | 51b0b25587d69593eb77e3337e3fa459c1024f5c (patch) | |
tree | 77c93c14fbbe1e4df15c957c63baefcfe6473669 /swaymsg/main.c | |
parent | Revert "Merge pull request #1943 from RyanDwyer/criteria-improvements" (diff) | |
parent | Fix conflicting IPC command type constants with i3's (diff) | |
download | sway-51b0b25587d69593eb77e3337e3fa459c1024f5c.tar.gz sway-51b0b25587d69593eb77e3337e3fa459c1024f5c.tar.zst sway-51b0b25587d69593eb77e3337e3fa459c1024f5c.zip |
Merge pull request #1959 from RyanDwyer/ipc-get-seats
Implement IPC get_seats command
Diffstat (limited to 'swaymsg/main.c')
-rw-r--r-- | swaymsg/main.c | 37 |
1 files changed, 36 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) { |