aboutsummaryrefslogtreecommitdiff
path: root/swaymsg
diff options
context:
space:
mode:
Diffstat (limited to 'swaymsg')
-rw-r--r--swaymsg/main.c37
-rw-r--r--swaymsg/swaymsg.1.scd66
-rw-r--r--swaymsg/swaymsg.1.txt3
3 files changed, 105 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) {
json_object_get_int(vendor));
}
+static void pretty_print_seat(json_object *i) {
+ json_object *name, *capabilities, *devices;
+ json_object_object_get_ex(i, "name", &name);
+ json_object_object_get_ex(i, "capabilities", &capabilities);
+ json_object_object_get_ex(i, "devices", &devices);
+
+ const char *fmt =
+ "Seat: %s\n"
+ " Capabilities: %d\n";
+
+ printf(fmt, json_object_get_string(name),
+ json_object_get_int(capabilities));
+
+ size_t devices_len = json_object_array_length(devices);
+ if (devices_len > 0) {
+ printf(" Devices:\n");
+ for (size_t i = 0; i < devices_len; ++i) {
+ json_object *device = json_object_array_get_idx(devices, i);
+
+ json_object *device_name;
+ json_object_object_get_ex(device, "name", &device_name);
+
+ printf(" %s\n", json_object_get_string(device_name));
+ }
+ }
+
+ printf("\n");
+}
+
static void pretty_print_output(json_object *o) {
json_object *name, *rect, *focused, *active, *ws;
json_object_object_get_ex(o, "name", &name);
@@ -211,7 +240,8 @@ static void pretty_print_clipboard(json_object *v) {
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_CLIPBOARD) {
+ type != IPC_GET_VERSION && type != IPC_GET_CLIPBOARD &&
+ type != IPC_GET_SEATS) {
printf("%s\n", json_object_to_json_string_ext(resp,
JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED));
return;
@@ -244,6 +274,9 @@ static void pretty_print(int type, json_object *resp) {
case IPC_GET_OUTPUTS:
pretty_print_output(obj);
break;
+ case IPC_GET_SEATS:
+ pretty_print_seat(obj);
+ break;
}
}
}
@@ -324,6 +357,8 @@ int main(int argc, char **argv) {
type = IPC_COMMAND;
} else if (strcasecmp(cmdtype, "get_workspaces") == 0) {
type = IPC_GET_WORKSPACES;
+ } else if (strcasecmp(cmdtype, "get_seats") == 0) {
+ type = IPC_GET_SEATS;
} else if (strcasecmp(cmdtype, "get_inputs") == 0) {
type = IPC_GET_INPUTS;
} else if (strcasecmp(cmdtype, "get_outputs") == 0) {
diff --git a/swaymsg/swaymsg.1.scd b/swaymsg/swaymsg.1.scd
new file mode 100644
index 00000000..1aa6a1b0
--- /dev/null
+++ b/swaymsg/swaymsg.1.scd
@@ -0,0 +1,66 @@
+swaymsg(1)
+
+# NAME
+
+swaymsg - Send messages to a running instance of sway over the IPC socket.
+
+# SYNOPSIS
+
+_swaymsg_ [options...] [message]
+
+# OPTIONS
+
+*-h, --help*
+ Show help message and quit.
+
+*-q, --quiet*
+ Sends the IPC message but does not print the response from sway.
+
+*-r, --raw*
+ Use raw output even if using a tty.
+
+*-s, --socket* <path>
+ Use the specified socket path. Otherwise, swaymsg will ask sway where the
+ socket is (which is the value of $SWAYSOCK, then of $I3SOCK).
+
+*-t, --type* <type>
+ Specify the type of IPC message. See below.
+
+*-v, --version*
+ Print the version (of swaymsg) and quit.
+
+# IPC MESSAGE TYPES
+
+*<command>*
+ The message is a sway command (the same commands you can bind to keybindings
+ in your sway config file). It will be executed immediately.
+
+ See **sway**(5) for a list of commands.
+
+*get\_workspaces*
+ Gets a JSON-encoded list of workspaces and their status.
+
+*get\_inputs*
+ Gets a JSON-encoded list of current inputs.
+
+*get\_outputs*
+ Gets a JSON-encoded list of current outputs.
+
+*get\_tree*
+ Gets a JSON-encoded layout tree of all open windows, containers, outputs,
+ workspaces, and so on.
+
+*get\_marks*
+ Get a JSON-encoded list of marks.
+
+*get\_bar\_config*
+ Get a JSON-encoded configuration for swaybar.
+
+*get\_version*
+ Get JSON-encoded version information for the running instance of sway.
+
+*get\_clipboard*
+ Get JSON-encoded information about the clipboard.
+ Returns the current clipboard mime-types if called without
+ arguments, otherwise returns the clipboard data in the requested
+ formats. Encodes the data using base64 for non-text mime types.
diff --git a/swaymsg/swaymsg.1.txt b/swaymsg/swaymsg.1.txt
index abc517c8..52209b12 100644
--- a/swaymsg/swaymsg.1.txt
+++ b/swaymsg/swaymsg.1.txt
@@ -48,6 +48,9 @@ IPC Message Types
*get_workspaces*::
Gets a JSON-encoded list of workspaces and their status.
+*get_seats*::
+ Gets a JSON-encoded list of current seats.
+
*get_inputs*::
Gets a JSON-encoded list of current inputs.