aboutsummaryrefslogtreecommitdiffstats
path: root/swaymsg
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2018-07-08 20:34:47 +0100
committerLibravatar Ian Fan <ianfan0@gmail.com>2018-07-10 12:37:37 +0100
commit23c1c26c3fedf5470dbee9fe97c2374a48588863 (patch)
tree751b5569e4e05149c7a7cd7e0d8084be5ff62063 /swaymsg
parentAdd get_binding_modes message type to ipc (diff)
downloadsway-23c1c26c3fedf5470dbee9fe97c2374a48588863.tar.gz
sway-23c1c26c3fedf5470dbee9fe97c2374a48588863.tar.zst
sway-23c1c26c3fedf5470dbee9fe97c2374a48588863.zip
Add get_config message type to ipc
Diffstat (limited to 'swaymsg')
-rw-r--r--swaymsg/main.c15
-rw-r--r--swaymsg/swaymsg.1.scd3
2 files changed, 17 insertions, 1 deletions
diff --git a/swaymsg/main.c b/swaymsg/main.c
index 42e488f3..4c068f69 100644
--- a/swaymsg/main.c
+++ b/swaymsg/main.c
@@ -240,6 +240,12 @@ 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
243static void pretty_print_config(json_object *c) {
244 json_object *config;
245 json_object_object_get_ex(c, "config", &config);
246 printf("%s\n", json_object_get_string(config));
247}
248
243static void pretty_print_clipboard(json_object *v) { 249static void pretty_print_clipboard(json_object *v) {
244 if (success(v, true)) { 250 if (success(v, true)) {
245 if (json_object_is_type(v, json_type_array)) { 251 if (json_object_is_type(v, json_type_array)) {
@@ -277,7 +283,7 @@ static void pretty_print(int type, json_object *resp) {
277 if (type != IPC_COMMAND && type != IPC_GET_WORKSPACES && 283 if (type != IPC_COMMAND && type != IPC_GET_WORKSPACES &&
278 type != IPC_GET_INPUTS && type != IPC_GET_OUTPUTS && 284 type != IPC_GET_INPUTS && type != IPC_GET_OUTPUTS &&
279 type != IPC_GET_VERSION && type != IPC_GET_CLIPBOARD && 285 type != IPC_GET_VERSION && type != IPC_GET_CLIPBOARD &&
280 type != IPC_GET_SEATS) { 286 type != IPC_GET_SEATS && type != IPC_GET_CONFIG) {
281 printf("%s\n", json_object_to_json_string_ext(resp, 287 printf("%s\n", json_object_to_json_string_ext(resp,
282 JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED)); 288 JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED));
283 return; 289 return;
@@ -288,6 +294,11 @@ static void pretty_print(int type, json_object *resp) {
288 return; 294 return;
289 } 295 }
290 296
297 if (type == IPC_GET_CONFIG) {
298 pretty_print_config(resp);
299 return;
300 }
301
291 if (type == IPC_GET_CLIPBOARD) { 302 if (type == IPC_GET_CLIPBOARD) {
292 pretty_print_clipboard(resp); 303 pretty_print_clipboard(resp);
293 return; 304 return;
@@ -409,6 +420,8 @@ int main(int argc, char **argv) {
409 type = IPC_GET_VERSION; 420 type = IPC_GET_VERSION;
410 } else if (strcasecmp(cmdtype, "get_binding_modes") == 0) { 421 } else if (strcasecmp(cmdtype, "get_binding_modes") == 0) {
411 type = IPC_GET_BINDING_MODES; 422 type = IPC_GET_BINDING_MODES;
423 } else if (strcasecmp(cmdtype, "get_config") == 0) {
424 type = IPC_GET_CONFIG;
412 } else if (strcasecmp(cmdtype, "get_clipboard") == 0) { 425 } else if (strcasecmp(cmdtype, "get_clipboard") == 0) {
413 type = IPC_GET_CLIPBOARD; 426 type = IPC_GET_CLIPBOARD;
414 } else { 427 } else {
diff --git a/swaymsg/swaymsg.1.scd b/swaymsg/swaymsg.1.scd
index f9b600b9..59a706d4 100644
--- a/swaymsg/swaymsg.1.scd
+++ b/swaymsg/swaymsg.1.scd
@@ -62,6 +62,9 @@ _swaymsg_ [options...] [message]
62*get\_binding\_modes* 62*get\_binding\_modes*
63 Gets a JSON-encoded list of currently configured binding modes. 63 Gets a JSON-encoded list of currently configured binding modes.
64 64
65*get\_config*
66 Gets a JSON-encoded copy of the current configuration.
67
65*get\_clipboard* 68*get\_clipboard*
66 Get JSON-encoded information about the clipboard. 69 Get JSON-encoded information about the clipboard.
67 Returns the current clipboard mime-types if called without 70 Returns the current clipboard mime-types if called without