LinuxCommandLibrary

swaymsg

TLDR

Send command

$ swaymsg [command]
copy
Get workspaces
$ swaymsg -t get_workspaces
copy
Get outputs
$ swaymsg -t get_outputs
copy
Get focused window
$ swaymsg -t get_tree | jq '.. | select(.focused?)'
copy
Reload configuration
$ swaymsg reload
copy
Exit sway
$ swaymsg exit
copy
Move workspace
$ swaymsg move workspace to output [HDMI-A-1]
copy

SYNOPSIS

swaymsg [-t type] [-m] [options] message

DESCRIPTION

swaymsg communicates with Sway window manager. It sends commands and queries state.
Commands control window management. Move, resize, focus operations.
Get queries return JSON data. Parse with jq for specific info.
Monitor mode watches events. See changes in real-time.
Socket path defaults to SWAYSOCK. Override for specific instance.

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.

SEE ALSO

sway(1), jq(1), i3-msg(1)

Copied to clipboard