diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-11 23:51:47 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-12 18:17:36 +1000 |
commit | c72940837c24b5df99c95667befe2e4e5c64575a (patch) | |
tree | eae77f45803c33f0825ee134956b9dac292a52b1 /swaymsg/main.c | |
parent | Merge pull request #1952 from Dudemanguy911/fix-crash-on-fullscreen (diff) | |
download | sway-c72940837c24b5df99c95667befe2e4e5c64575a.tar.gz sway-c72940837c24b5df99c95667befe2e4e5c64575a.tar.zst sway-c72940837c24b5df99c95667befe2e4e5c64575a.zip |
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) { |