aboutsummaryrefslogtreecommitdiff
path: root/swaymsg
diff options
context:
space:
mode:
authornyorain <nyorain@gmail.com>2017-07-07 15:38:45 +0200
committernyorain <nyorain@gmail.com>2017-07-07 15:38:45 +0200
commit02c75ebe37d50ff97c4fd8b6be169ac4e1074b07 (patch)
treedc5f4295e0b988b2f8746507a2fadfbda7b8d881 /swaymsg
parent23a1e944027265c70654d7395362641b59428062 (diff)
Implement ipc get_clipboard
Diffstat (limited to 'swaymsg')
-rw-r--r--swaymsg/main.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/swaymsg/main.c b/swaymsg/main.c
index efd0ec25..fa28553b 100644
--- a/swaymsg/main.c
+++ b/swaymsg/main.c
@@ -144,10 +144,23 @@ static void pretty_print_version(json_object *v) {
printf("sway version %s\n", json_object_get_string(ver));
}
+static void pretty_print_clipboard(json_object *v) {
+ bool _success;
+ json_object *success;
+ json_object_object_get_ex(v, "success", &success);
+ _success = json_object_get_boolean(success);
+
+ if (_success) {
+ json_object *ver;
+ json_object_object_get_ex(v, "content", &ver);
+ printf("%s\n", json_object_get_string(ver));
+ }
+}
+
static void pretty_print(int type, json_object *resp) {
if (type != IPC_COMMAND && type != IPC_GET_WORKSPACES &&
type != IPC_GET_INPUTS && type != IPC_GET_OUTPUTS &&
- type != IPC_GET_VERSION) {
+ type != IPC_GET_VERSION && type != IPC_GET_CLIPBOARD) {
printf("%s\n", json_object_to_json_string_ext(resp,
JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED));
return;
@@ -158,6 +171,11 @@ static void pretty_print(int type, json_object *resp) {
return;
}
+ if (type == IPC_GET_CLIPBOARD) {
+ pretty_print_clipboard(resp);
+ return;
+ }
+
json_object *obj;
size_t len = json_object_array_length(resp);
for (size_t i = 0; i < len; ++i) {
@@ -267,6 +285,8 @@ int main(int argc, char **argv) {
type = IPC_GET_BAR_CONFIG;
} else if (strcasecmp(cmdtype, "get_version") == 0) {
type = IPC_GET_VERSION;
+ } else if (strcasecmp(cmdtype, "get_clipboard") == 0) {
+ type = IPC_GET_CLIPBOARD;
} else {
sway_abort("Unknown message type %s", cmdtype);
}