sway man page

A sway configuration file is a list of sway commands that are executed by sway on startup. These commands usually consist of setting your preferences and setting key bindings. An example config is likely present in /etc/sway/config for you to check out.

Lines in the configuration file might be extended through multiple lines by adding a \ character at the end of line. e.g.:

Direction may be one of up, down, left, right, next, prev, parent, or child. The directional focus commands will move the focus in that direction. The next and prev directions will focus the next, respectively previous, element in the current container. The parent focus command will change the focus to the parent of the currently focused container, which is useful, for example, to open a sibling of the parent container, or to move the entire container around.

Direction may be one of up, down, left, right. The directional focus commands will move the focus to the output in that direction. When name is given, the focus is changed to the output with that name.

Modify the number of master elements, respectively slave columns, in the focused container. <n> can be a positive or negative integer. These commands only have an effect if the focused container uses one of the "auto" layouts.

Moving to prev or next swaps the container with its sibling in the same container. Move first exchanges the focused element in an auto layout with the first element, i.e. promotes the focused element to master position.

Resizes the currently focused container or view by amount. amount is optional: the default value is 10 (either px or ppt depending on the view type). The [px|ppt] parameter is optional. px specifies that amount refers to pixels; ppt specifies that amount refers to percentage points of the current dimension. Floating views use px dimensions by default (but can use ppt if specified); tiled views use ppt dimensions by default (but can use px if specified).

resize set <width> [px] <height> [px]

Sets the width and height of the currently focused container to width pixels and height pixels. The [px] parameters are optional and have no effect. This command only accepts pixel dimensions.

Binds key combo to execute command when pressed. You may use XKB key names here (xev(1) is a good tool for discovering them). An example bindsym command would be bindsym Mod1+Shift+f exec firefox, which would execute Firefox if the alt, shift, and F keys are pressed together. Any valid sway command is eligible to be bound to a key combo.

bindcode <code> <command> is also available for binding with key codes instead of key names.

The client commands control the colors of the view borders and title bars. All client commands require five color values. (The one exception is client.background which requires one color value.) If you only want to specify a subset, supply default colors for all the others. Colors must be defined in hex. i.e. #rrggbb or #rrggbbaa, when including the alpha channel.

The command tokens are:

color_class

Specifies the view to which the colors apply.

client.background

The color a view will be painted, underneath the client itself. This will only be visible if a client does not fully cover its allocated view space. This command only requires one color. Note: This is not currently implemented.

client.focused

The view that has focus.

client.focused_inactive

A view that has focus within its container, but the container is not focused.

client.placeholder

Used when drawing placeholder view contents. Only background and text colors are used. Note: This is not currently implemented.

client.unfocused

A view that does not have focus.

client.urgent

A view with an urgency hint. Note: This is not currently implemented.

border

The border around the title bar.

background

The background of the title bar.

text

The text color of the title bar.

indicator

The color used to indicate where a new view will open. In a tiled container, this would paint the right border of the current view if a new view would be opened to the right.

Set default border style for new floating windows. This only applies to windows that are spawned in floating mode, not windows that become floating after the fact. This command was previously called new_float. While new_float still works, it is considered deprecated and support for it will be removed in the future.

Specifies the maximum dimensions of floating windows. Uses the container dimensions as default. -1 x -1 will remove any restriction on dimensions. 0 x 0 has the same behavior as not setting any value. If in conflict, this option has precedence over floating_minimum_size.

When the modifier key is held down, you may hold left click to move floating windows, and right click to resize them. Unlike i3, this modifier may also be used to resize and move windows that are tiled. With the inverse mode enabled, left click is used for resizing and right click for dragging. The mode parameter is optional and defaults to normal if it isn’t defined.

Whether or not to add gaps between views and workspace edges if amount of inner gap is not zero. When off, no gap is added where the view is aligned to the workspace edge, effectively creating gaps only between views. The toggle argument cannot be used in the configuration file.

Changes the gaps for the inner or outer gap. all changes the gaps for all views or workspace, workspace changes gaps for all views in current workspace (or current workspace), and current changes gaps for the current view or workspace.

Marks are arbitrary labels that can be used to identify certain windows and then jump to them at a later time. By default, the mark command sets identifier as the only mark on a window. By specifying --add, mark will add identifier to the list of current marks. If --toggle is specified mark will remove identifier if it is already a label. Marks may be found by using a criteria. See the Criteria section below.

Switches to the given mode_name. The default mode is simply default. To create a new mode append { to this command, the following lines will be keybindings for that mode, and } on its own line to close the block.

Switches to the specified workspace. The string "number" is optional. The workspace name, if unquoted, may not contain the string "output", as sway will assume that the command is moving a workspace to an output, as described below.

When yes, repeating a workspace switch command will switch back to the prior workspace. For example, if you are currently on workspace 1, switch to workspace 2, then invoke the "workspace 2" command again, you will be returned to workspace 1. Defaults to no.

The string contains one or more (space separated) attribute/value pairs. They are used by some commands to choose which views to execute actions on. All attributes must match for the criteria to match.

Criteria may be used with either the for_window or assign commands to specify operations to perform on new views. A criteria may also be used to perform specific commands (ones that normally act upon one window) on all views that match that criteria. For example: