diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-07-23 20:27:56 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-07-23 20:31:11 -0400 |
commit | f4b882475eee7a81c206c7825616cc4656b2f60b (patch) | |
tree | 38e6ebf81b235424f105dcbcbb194e5e9eac70c0 /swaymsg/main.c | |
parent | Implement pid->workspace tracking (diff) | |
parent | Merge pull request #2342 from RyanDwyer/update-cursor (diff) | |
download | sway-f4b882475eee7a81c206c7825616cc4656b2f60b.tar.gz sway-f4b882475eee7a81c206c7825616cc4656b2f60b.tar.zst sway-f4b882475eee7a81c206c7825616cc4656b2f60b.zip |
Merge branch 'master' into pid-workspaces
Diffstat (limited to 'swaymsg/main.c')
-rw-r--r-- | swaymsg/main.c | 51 |
1 files changed, 13 insertions, 38 deletions
diff --git a/swaymsg/main.c b/swaymsg/main.c index 4283bf00..c4141ca5 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c | |||
@@ -240,44 +240,17 @@ static void pretty_print_version(json_object *v) { | |||
240 | printf("sway version %s\n", json_object_get_string(ver)); | 240 | printf("sway version %s\n", json_object_get_string(ver)); |
241 | } | 241 | } |
242 | 242 | ||
243 | static void pretty_print_clipboard(json_object *v) { | 243 | static void pretty_print_config(json_object *c) { |
244 | if (success(v, true)) { | 244 | json_object *config; |
245 | if (json_object_is_type(v, json_type_array)) { | 245 | json_object_object_get_ex(c, "config", &config); |
246 | for (size_t i = 0; i < json_object_array_length(v); ++i) { | 246 | printf("%s\n", json_object_get_string(config)); |
247 | json_object *o = json_object_array_get_idx(v, i); | ||
248 | printf("%s\n", json_object_get_string(o)); | ||
249 | } | ||
250 | } else { | ||
251 | // NOTE: could be extended to print all received types | ||
252 | // instead just the first one when sways ipc server | ||
253 | // supports it | ||
254 | struct json_object_iterator iter = json_object_iter_begin(v); | ||
255 | struct json_object_iterator end = json_object_iter_end(v); | ||
256 | if (!json_object_iter_equal(&iter, &end)) { | ||
257 | json_object *obj = json_object_iter_peek_value(&iter); | ||
258 | if (success(obj, false)) { | ||
259 | json_object *content; | ||
260 | json_object_object_get_ex(obj, "content", &content); | ||
261 | printf("%s\n", json_object_get_string(content)); | ||
262 | } else { | ||
263 | json_object *error; | ||
264 | json_object_object_get_ex(obj, "error", &error); | ||
265 | printf("Error: %s\n", json_object_get_string(error)); | ||
266 | } | ||
267 | } | ||
268 | } | ||
269 | } else { | ||
270 | json_object *error; | ||
271 | json_object_object_get_ex(v, "error", &error); | ||
272 | printf("Error: %s\n", json_object_get_string(error)); | ||
273 | } | ||
274 | } | 247 | } |
275 | 248 | ||
276 | static void pretty_print(int type, json_object *resp) { | 249 | static void pretty_print(int type, json_object *resp) { |
277 | if (type != IPC_COMMAND && type != IPC_GET_WORKSPACES && | 250 | if (type != IPC_COMMAND && type != IPC_GET_WORKSPACES && |
278 | type != IPC_GET_INPUTS && type != IPC_GET_OUTPUTS && | 251 | type != IPC_GET_INPUTS && type != IPC_GET_OUTPUTS && |
279 | type != IPC_GET_VERSION && type != IPC_GET_CLIPBOARD && | 252 | type != IPC_GET_VERSION && type != IPC_GET_SEATS && |
280 | type != IPC_GET_SEATS) { | 253 | type != IPC_GET_CONFIG) { |
281 | printf("%s\n", json_object_to_json_string_ext(resp, | 254 | printf("%s\n", json_object_to_json_string_ext(resp, |
282 | JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED)); | 255 | JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED)); |
283 | return; | 256 | return; |
@@ -288,8 +261,8 @@ static void pretty_print(int type, json_object *resp) { | |||
288 | return; | 261 | return; |
289 | } | 262 | } |
290 | 263 | ||
291 | if (type == IPC_GET_CLIPBOARD) { | 264 | if (type == IPC_GET_CONFIG) { |
292 | pretty_print_clipboard(resp); | 265 | pretty_print_config(resp); |
293 | return; | 266 | return; |
294 | } | 267 | } |
295 | 268 | ||
@@ -323,7 +296,7 @@ int main(int argc, char **argv) { | |||
323 | char *socket_path = NULL; | 296 | char *socket_path = NULL; |
324 | char *cmdtype = NULL; | 297 | char *cmdtype = NULL; |
325 | 298 | ||
326 | wlr_log_init(L_INFO, NULL); | 299 | wlr_log_init(WLR_INFO, NULL); |
327 | 300 | ||
328 | static struct option long_options[] = { | 301 | static struct option long_options[] = { |
329 | {"help", no_argument, NULL, 'h'}, | 302 | {"help", no_argument, NULL, 'h'}, |
@@ -407,8 +380,10 @@ int main(int argc, char **argv) { | |||
407 | type = IPC_GET_BAR_CONFIG; | 380 | type = IPC_GET_BAR_CONFIG; |
408 | } else if (strcasecmp(cmdtype, "get_version") == 0) { | 381 | } else if (strcasecmp(cmdtype, "get_version") == 0) { |
409 | type = IPC_GET_VERSION; | 382 | type = IPC_GET_VERSION; |
410 | } else if (strcasecmp(cmdtype, "get_clipboard") == 0) { | 383 | } else if (strcasecmp(cmdtype, "get_binding_modes") == 0) { |
411 | type = IPC_GET_CLIPBOARD; | 384 | type = IPC_GET_BINDING_MODES; |
385 | } else if (strcasecmp(cmdtype, "get_config") == 0) { | ||
386 | type = IPC_GET_CONFIG; | ||
412 | } else { | 387 | } else { |
413 | sway_abort("Unknown message type %s", cmdtype); | 388 | sway_abort("Unknown message type %s", cmdtype); |
414 | } | 389 | } |