aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--completions/zsh/_swaymsg1
-rw-r--r--include/ipc.h3
-rw-r--r--include/sway/commands.h1
-rw-r--r--include/sway/config.h5
-rw-r--r--swaymsg/main.c44
-rw-r--r--swaymsg/swaymsg.1.scd6
6 files changed, 5 insertions, 55 deletions
diff --git a/completions/zsh/_swaymsg b/completions/zsh/_swaymsg
index 6bb03279..2e39deb6 100644
--- a/completions/zsh/_swaymsg
+++ b/completions/zsh/_swaymsg
@@ -22,7 +22,6 @@ types=(
22'get_marks' 22'get_marks'
23'get_bar_config' 23'get_bar_config'
24'get_version' 24'get_version'
25'get_clipboard'
26) 25)
27 26
28_arguments -s \ 27_arguments -s \
diff --git a/include/ipc.h b/include/ipc.h
index 6f6795b3..0010718b 100644
--- a/include/ipc.h
+++ b/include/ipc.h
@@ -18,8 +18,7 @@ enum ipc_command_type {
18 18
19 // sway-specific command types 19 // sway-specific command types
20 IPC_GET_INPUTS = 100, 20 IPC_GET_INPUTS = 100,
21 IPC_GET_CLIPBOARD = 101, 21 IPC_GET_SEATS = 101,
22 IPC_GET_SEATS = 102,
23 22
24 // Events sent from sway to clients. Events have the highest bits set. 23 // Events sent from sway to clients. Events have the highest bits set.
25 IPC_EVENT_WORKSPACE = ((1<<31) | 0), 24 IPC_EVENT_WORKSPACE = ((1<<31) | 0),
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 6d17144a..dda0606a 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -95,7 +95,6 @@ sway_cmd cmd_client_unfocused;
95sway_cmd cmd_client_urgent; 95sway_cmd cmd_client_urgent;
96sway_cmd cmd_client_placeholder; 96sway_cmd cmd_client_placeholder;
97sway_cmd cmd_client_background; 97sway_cmd cmd_client_background;
98sway_cmd cmd_clipboard;
99sway_cmd cmd_commands; 98sway_cmd cmd_commands;
100sway_cmd cmd_debuglog; 99sway_cmd cmd_debuglog;
101sway_cmd cmd_default_border; 100sway_cmd cmd_default_border;
diff --git a/include/sway/config.h b/include/sway/config.h
index d5e4116f..99575274 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -271,11 +271,10 @@ enum ipc_feature {
271 IPC_FEATURE_EVENT_WINDOW = 2048, 271 IPC_FEATURE_EVENT_WINDOW = 2048,
272 IPC_FEATURE_EVENT_BINDING = 4096, 272 IPC_FEATURE_EVENT_BINDING = 4096,
273 IPC_FEATURE_EVENT_INPUT = 8192, 273 IPC_FEATURE_EVENT_INPUT = 8192,
274 IPC_FEATURE_GET_CLIPBOARD = 16384, 274 IPC_FEATURE_GET_SEATS = 16384,
275 IPC_FEATURE_GET_SEATS = 32768,
276 275
277 IPC_FEATURE_ALL_COMMANDS = 276 IPC_FEATURE_ALL_COMMANDS =
278 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 16384 | 32768, 277 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 16384,
279 IPC_FEATURE_ALL_EVENTS = 256 | 512 | 1024 | 2048 | 4096 | 8192, 278 IPC_FEATURE_ALL_EVENTS = 256 | 512 | 1024 | 2048 | 4096 | 8192,
280 279
281 IPC_FEATURE_ALL = IPC_FEATURE_ALL_COMMANDS | IPC_FEATURE_ALL_EVENTS, 280 IPC_FEATURE_ALL = IPC_FEATURE_ALL_COMMANDS | IPC_FEATURE_ALL_EVENTS,
diff --git a/swaymsg/main.c b/swaymsg/main.c
index 4c068f69..c4141ca5 100644
--- a/swaymsg/main.c
+++ b/swaymsg/main.c
@@ -246,44 +246,11 @@ static void pretty_print_config(json_object *c) {
246 printf("%s\n", json_object_get_string(config)); 246 printf("%s\n", json_object_get_string(config));
247} 247}
248 248
249static void pretty_print_clipboard(json_object *v) {
250 if (success(v, true)) {
251 if (json_object_is_type(v, json_type_array)) {
252 for (size_t i = 0; i < json_object_array_length(v); ++i) {
253 json_object *o = json_object_array_get_idx(v, i);
254 printf("%s\n", json_object_get_string(o));
255 }
256 } else {
257 // NOTE: could be extended to print all received types
258 // instead just the first one when sways ipc server
259 // supports it
260 struct json_object_iterator iter = json_object_iter_begin(v);
261 struct json_object_iterator end = json_object_iter_end(v);
262 if (!json_object_iter_equal(&iter, &end)) {
263 json_object *obj = json_object_iter_peek_value(&iter);
264 if (success(obj, false)) {
265 json_object *content;
266 json_object_object_get_ex(obj, "content", &content);
267 printf("%s\n", json_object_get_string(content));
268 } else {
269 json_object *error;
270 json_object_object_get_ex(obj, "error", &error);
271 printf("Error: %s\n", json_object_get_string(error));
272 }
273 }
274 }
275 } else {
276 json_object *error;
277 json_object_object_get_ex(v, "error", &error);
278 printf("Error: %s\n", json_object_get_string(error));
279 }
280}
281
282static void pretty_print(int type, json_object *resp) { 249static void pretty_print(int type, json_object *resp) {
283 if (type != IPC_COMMAND && type != IPC_GET_WORKSPACES && 250 if (type != IPC_COMMAND && type != IPC_GET_WORKSPACES &&
284 type != IPC_GET_INPUTS && type != IPC_GET_OUTPUTS && 251 type != IPC_GET_INPUTS && type != IPC_GET_OUTPUTS &&
285 type != IPC_GET_VERSION && type != IPC_GET_CLIPBOARD && 252 type != IPC_GET_VERSION && type != IPC_GET_SEATS &&
286 type != IPC_GET_SEATS && type != IPC_GET_CONFIG) { 253 type != IPC_GET_CONFIG) {
287 printf("%s\n", json_object_to_json_string_ext(resp, 254 printf("%s\n", json_object_to_json_string_ext(resp,
288 JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED)); 255 JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED));
289 return; 256 return;
@@ -299,11 +266,6 @@ static void pretty_print(int type, json_object *resp) {
299 return; 266 return;
300 } 267 }
301 268
302 if (type == IPC_GET_CLIPBOARD) {
303 pretty_print_clipboard(resp);
304 return;
305 }
306
307 json_object *obj; 269 json_object *obj;
308 size_t len = json_object_array_length(resp); 270 size_t len = json_object_array_length(resp);
309 for (size_t i = 0; i < len; ++i) { 271 for (size_t i = 0; i < len; ++i) {
@@ -422,8 +384,6 @@ int main(int argc, char **argv) {
422 type = IPC_GET_BINDING_MODES; 384 type = IPC_GET_BINDING_MODES;
423 } else if (strcasecmp(cmdtype, "get_config") == 0) { 385 } else if (strcasecmp(cmdtype, "get_config") == 0) {
424 type = IPC_GET_CONFIG; 386 type = IPC_GET_CONFIG;
425 } else if (strcasecmp(cmdtype, "get_clipboard") == 0) {
426 type = IPC_GET_CLIPBOARD;
427 } else { 387 } else {
428 sway_abort("Unknown message type %s", cmdtype); 388 sway_abort("Unknown message type %s", cmdtype);
429 } 389 }
diff --git a/swaymsg/swaymsg.1.scd b/swaymsg/swaymsg.1.scd
index 59a706d4..a6e279da 100644
--- a/swaymsg/swaymsg.1.scd
+++ b/swaymsg/swaymsg.1.scd
@@ -64,9 +64,3 @@ _swaymsg_ [options...] [message]
64 64
65*get\_config* 65*get\_config*
66 Gets a JSON-encoded copy of the current configuration. 66 Gets a JSON-encoded copy of the current configuration.
67
68*get\_clipboard*
69 Get JSON-encoded information about the clipboard.
70 Returns the current clipboard mime-types if called without
71 arguments, otherwise returns the clipboard data in the requested
72 formats. Encodes the data using base64 for non-text mime types.