swaymsg
Send IPC commands to Sway compositor
TLDR
SYNOPSIS
swaymsg [-t type] [-m] [options] message
DESCRIPTION
swaymsg is the IPC (Inter-Process Communication) client for the Sway Wayland compositor. It sends commands and queries to a running Sway instance via the IPC socket, enabling scripted control of window management operations like moving, resizing, and focusing windows.Query message types (getworkspaces, getoutputs, get_tree) return JSON data describing the current compositor state, which can be parsed with tools like jq. This makes swaymsg useful for building custom status bars, automation scripts, and workspace management tools.Monitor mode subscribes to Sway events and prints them in real time, useful for debugging and building reactive scripts. The IPC socket path defaults to the SWAYSOCK environment variable set by Sway.
PARAMETERS
-t, --type TYPE
Message type.-m, --monitor
Monitor for responses until killed. Can only be used with the subscribe message type.-p, --pretty
Use pretty output even when not using a tty.-r, --raw
Use raw JSON output even when using a tty.-q, --quiet
Send the IPC message but do not print the response.-s, --socket PATH
Use the specified socket path instead of SWAYSOCK environment variable.
MESSAGE TYPES
get_workspaces - List workspaces and their statusget_outputs - List outputs and their propertiesget_tree - JSON-encoded layout tree of all windows, containers, outputs, and workspacesget_marks - List of window marksget_bar_config - Bar configurationget_version - Sway version informationget_inputs - List current inputsget_seats - List seats and assigned devicesget_binding_modes - List configured binding modessubscribe - Subscribe to event types (use with -m)
CAVEATS
Sway must be running. Socket permissions required. JSON output needs parsing.
HISTORY
swaymsg is the IPC client for Sway compositor. It mirrors i3-msg functionality for Wayland.
