swaymsg
Send IPC commands to Sway compositor
TLDR
Send command
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.-r, --raw
Raw output.-q, --quiet
Quiet mode.-s, --socket PATH
Socket path.
MESSAGE TYPES
get_workspaces - List workspaces
get_outputs - List outputs
get_tree - Window tree
get_marks - Window marks
get_bar_config - Bar config
get_version - Sway version
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.
