Sway is a work-in-progress so caution is advised. However, the project's creator, [https://drewdevault.com/ Drew DeVault] (aka SirCmpwn) has deemed it ready for regular use.

Sway is a work-in-progress so caution is advised. However, the project's creator, [https://drewdevault.com/ Drew DeVault] (aka SirCmpwn) has deemed it ready for regular use.

Line 16:

Line 17:

== Installation ==

== Installation ==

−

''sway'' can be [[installed]] with the {{Pkg|sway}} package.

+

''sway'' can be [[install]]ed with the {{Pkg|sway}} package. This will install the stable (but abandoned) ''0.15'' version which is based on the (also abandoned) [https://github.com/Cloudef/wlc wlc] library.

+

+

At the time of writing, ''sway 1.0-beta'' (based on the new [https://github.com/swaywm/wlroots wlroots] library) is under active development and quite stable.

+

Install the following two [[Arch User Repository]] packages instead: {{AUR|wlroots-git}} and {{AUR|sway-git}}.

+

+

It's advisable to always update ''wlroots'' when you update ''sway'', due to tight dependencies.

−

== Starting sway ==

+

== Starting ==

{{Tip|See [[Wayland#GUI libraries]] for appropriate environment variables to set for window decoration libraries.}}

{{Tip|See [[Wayland#GUI libraries]] for appropriate environment variables to set for window decoration libraries.}}

−

=== From a TTY, on login ===

+

=== From a TTY ===

−

You can start sway by simply typing {{ic|sway}} from your TTY. To start sway from tty1 on login with default US keyboard edit {{ic|.bash_profile}} use this code:

+

To start Sway, simply type ''sway'' from a TTY.

−

{{hc|~/.bash_profile|

+

=== From a display manager ===

−

<nowiki>if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then

−

XKB_DEFAULT_LAYOUT=us exec sway

−

fi</nowiki>

−

}}

−

−

=== Using a display manager ===

{{Note|Sway does not support display managers officially.}}

{{Note|Sway does not support display managers officially.}}

Line 44:

Line 44:

=== Keymap ===

=== Keymap ===

−

By default, sway starts with the US QWERTY keymap. You can override this behaviour by starting sway with

+

By default, sway starts with the US QWERTY keymap. You can override this behaviour by starting sway with:

If you want multiple keyboard layouts at startup edit {{ic|.bash_profile}} and add, for example US English and German layouts, switchable by Mod+Space:

+

If you want multiple keyboard layouts at startup edit {{ic|.bash_profile}} and add, for example US English and German layouts, switchable by {{ic|Mod+Space}}:

{{hc|~/.bash_profile|

{{hc|~/.bash_profile|

Line 75:

Line 68:

}}

}}

−

Other options for switching keyboard layout is Alt+Shift: ''grp:alt_shift_toggle''

+

Another option for switching keyboard layout is {{ic|Alt}}+{{ic|Shift}}: {{ic|grp:alt_shift_toggle}}.

=== Statusbar ===

=== Statusbar ===

+

Installing the program {{Pkg|i3status}} is an easy way to get a practical, default statusbar. All one has to do is add following snippet at the end of your sway config:

Installing the program {{Pkg|i3status}} is an easy way to get a practical, default statusbar. All one has to do is add following snippet at the end of your sway config:

+

{{hc|~/.config/sway/config|<nowiki>

{{hc|~/.config/sway/config|<nowiki>

bar {

bar {

Line 84:

Line 79:

}

}

</nowiki>}}

</nowiki>}}

+

If you want to achieve colored output of i3status, you can adjust following part in the i3status configuration:

If you want to achieve colored output of i3status, you can adjust following part in the i3status configuration:

+

{{hc|~/.config/i3status/config|<nowiki>

{{hc|~/.config/i3status/config|<nowiki>

general {

general {

Line 91:

Line 88:

}

}

</nowiki>}}

</nowiki>}}

+

In both examples, the system-wide installed configuration files has been copied over to the user directory and then modified.

In both examples, the system-wide installed configuration files has been copied over to the user directory and then modified.

=== Wallpaper ===

=== Wallpaper ===

+

This line, which can be appended at the end of your sway configuration, sets a background image on all displays (output matches all with name {{ic|"*"}}):

This line, which can be appended at the end of your sway configuration, sets a background image on all displays (output matches all with name {{ic|"*"}}):

+

{{hc|~/.config/sway/config|<nowiki>

{{hc|~/.config/sway/config|<nowiki>

output "*" background /home/onny/pictures/fredwang_norway.jpg fill

output "*" background /home/onny/pictures/fredwang_norway.jpg fill

</nowiki>}}

</nowiki>}}

+

Of course you have to replace the file name and path according to your wallpaper.

Of course you have to replace the file name and path according to your wallpaper.

=== Input devices ===

=== Input devices ===

+

Its possible to tweak specific input device configurations. For example to enable tap-to-click and natural scolling for a touchpad, add an input block:

Its possible to tweak specific input device configurations. For example to enable tap-to-click and natural scolling for a touchpad, add an input block:

+

{{hc|~/.config/sway/config|<nowiki>

{{hc|~/.config/sway/config|<nowiki>

input "2:14:ETPS/2_Elantech_Touchpad" {

input "2:14:ETPS/2_Elantech_Touchpad" {

Line 108:

Line 111:

}

}

</nowiki>}}

</nowiki>}}

+

Where as the device identifier can be queried with:

Where as the device identifier can be queried with:

+

swaymsg -t get_inputs

swaymsg -t get_inputs

Line 118:

Line 123:

Set your displays scale factor with the {{ic|output}} command in your config file. The scale factor must be an integer, and is usually 2 for HiDPI screens.

Set your displays scale factor with the {{ic|output}} command in your config file. The scale factor must be an integer, and is usually 2 for HiDPI screens.

+

output <name> scale <factor>

output <name> scale <factor>

+

You can find your display name with the following command:

You can find your display name with the following command:

+

swaymsg -t get_outputs

swaymsg -t get_outputs

=== Custom keybindings ===

=== Custom keybindings ===

+

[[Extra keyboard keys|Special keys]] on your keyboard can be used to execute commands, for example to control your volume or your monitor brightness:

[[Extra keyboard keys|Special keys]] on your keyboard can be used to execute commands, for example to control your volume or your monitor brightness:

Line 133:

Line 142:

</nowiki>}}

</nowiki>}}

−

To control brightness you can use {{AUR|brightnessctl}}. For a list of utilities to control brightness and color correction see [[Backlight]]

+

To control brightness you can use {{AUR|brightnessctl}}. For a list of utilities to control brightness and color correction see [[Backlight]].

−

=== .Xresources ===

+

=== Xresources ===

−

Copy {{ic|.Xresources}} to {{ic|.Xdefaults}} to use them in sway.

+

+

Copy {{ic|~/.Xresources}} to {{ic|~/.Xdefaults}} to use them in Sway.

== Tips and tricks ==

== Tips and tricks ==

+

+

=== Autostart on login ===

+

+

To start sway from tty1 on login with default US keyboard, edit:

+

+

{{hc|~/.bash_profile|

+

<nowiki>if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then

+

XKB_DEFAULT_LAYOUT=us exec sway

+

fi</nowiki>

+

}}

+

+

=== Backlight toggle ===

+

+

To turn off (and on) your displays with a key (e.g. {{ic|Pause}}) bind the following in your Sway {{ic|config}}:

+

+

#!/usr/bin/dash

+

read lcd < /tmp/lcd

+

if [ "$lcd" -eq "0" ]; then

+

swaymsg "output * dpms on"

+

echo 1 > /tmp/lcd

+

else

+

swaymsg "output * dpms off"

+

echo 0 > /tmp/lcd

+

fi

+

=== dmenu replacement ===

=== dmenu replacement ===

As dmenu runs on XWayland, the applicions tends to become unresponsive if the focus is moved elsewhere, requiring a sway restart, to fix the broken, always visible and unresponsive dmenu.

As dmenu runs on XWayland, the applicions tends to become unresponsive if the focus is moved elsewhere, requiring a sway restart, to fix the broken, always visible and unresponsive dmenu.

−

Rofi is a nice option, yet, to automatically focus rofi as a menu, it needs to be run from urxvt or other non-wayland-native virtual terminal. Invoking it as menu in sway will not focus on the menu (you have to hover the mouse on rofi, for rofi to grab your input)

+

−

One of the best workarounds could be found https://github.com/swaywm/sway/issues/1367#issuecomment-332910152 :

+

Rofi is a nice option, yet, to automatically focus rofi as a menu, it needs to be run from urxvt or other non-wayland-native virtual terminal. Invoking it as menu in sway will not focus on the menu (you have to hover the mouse on rofi, for rofi to grab your input).

+

+

One of the best workarounds can be found [https://github.com/swaywm/sway/issues/1367#issuecomment-332910152 here].

== Known issues ==

== Known issues ==

Line 149:

Line 186:

=== Using i3-dmenu-desktop ===

=== Using i3-dmenu-desktop ===

−

i3-dmenu-desktop is not usable directly from sway, but a patch is available here: https://github.com/i3/i3/pull/2265/files

+

i3-dmenu-desktop is not usable directly from sway, but a patch is available [https://github.com/i3/i3/pull/2265/files here]. Unfortunately, the patch cannot be merged because it breaks when used from i3 in some corner cases. See [https://github.com/SirCmpwn/sway/issues/521] for more information.

−

Unfortunately, the patch cannot be merged because it breaks when used from i3 in some corner cases.

−

See here for more information: https://github.com/SirCmpwn/sway/issues/521

+

You can still apply the patch manually through installing {{AUR|sway-dmenu-desktop}}{{Broken package link|package not found}}. This creates a new binary called {{ic|sway-dmenu-desktop}} to be using within sway.

−

−

You can still apply the patch manually through installing {{AUR|sway-dmenu-desktop}}. This creates a new binary called {{ic|sway-dmenu-desktop}} to be using within sway.

An alternative is to use {{AUR|j4-dmenu-desktop}}, which is advertised as faster than i3-dmenu-desktop.

An alternative is to use {{AUR|j4-dmenu-desktop}}, which is advertised as faster than i3-dmenu-desktop.

−

=== Using VirtualBox ===

+

=== VirtualBox ===

−

Sway doesn't work well (or at all) under VirtualBox.

+

Sway doesn't work well (or at all) under [[VirtualBox]].

=== Sway Socket Not Detected ===

=== Sway Socket Not Detected ===

−

Using a {{ic|swaymsg}} argument, such as {{ic|swaymsg -t get_outputs}}, will sometimes return the message

+

Using a {{ic|swaymsg}} argument, such as {{ic|swaymsg -t get_outputs}}, will sometimes return the message:

+

sway socket not detected.

sway socket not detected.

ERROR: Unable to connect to

ERROR: Unable to connect to

+

when run inside a terminal multiplexer (such as gnu screen or tmux). This means {{ic|swaymsg}} could not connect to the socket provided in your {{ic|SWAYSOCK}}.

when run inside a terminal multiplexer (such as gnu screen or tmux). This means {{ic|swaymsg}} could not connect to the socket provided in your {{ic|SWAYSOCK}}.

To view what the current value of {{ic|SWAYSOCK}} is, type:

To view what the current value of {{ic|SWAYSOCK}} is, type:

+

$ env | fgrep SWAYSOCK

$ env | fgrep SWAYSOCK

SWAYSOCK=/run/user/1000/sway-ipc.1000.4981.sock

SWAYSOCK=/run/user/1000/sway-ipc.1000.4981.sock

To work around this problem, you may try attaching to the first available sway socket, and retrying your command:

To work around this problem, you may try attaching to the first available sway socket, and retrying your command:

It's advisable to always update wlroots when you update sway, due to tight dependencies.

Starting

Tip: See Wayland#GUI libraries for appropriate environment variables to set for window decoration libraries.

From a TTY

To start Sway, simply type sway from a TTY.

From a display manager

Note: Sway does not support display managers officially.

The sway session is located at /usr/share/wayland-sessions/sway.desktop. It is automatically recognized by modern display managers like GDM and SDDM.

Configuration

If you already use i3, then copy your i3 configuration to ~/.config/sway/config and it should work out of the box. Otherwise, copy the sample configuration file to ~/.config/sway/config. It is located at /etc/sway/config, unless the DFALLBACK_CONFIG_DIR flag has been set. See sway(5) for information on the configuration.

Keymap

By default, sway starts with the US QWERTY keymap. You can override this behaviour by starting sway with:

dmenu replacement

As dmenu runs on XWayland, the applicions tends to become unresponsive if the focus is moved elsewhere, requiring a sway restart, to fix the broken, always visible and unresponsive dmenu.

Rofi is a nice option, yet, to automatically focus rofi as a menu, it needs to be run from urxvt or other non-wayland-native virtual terminal. Invoking it as menu in sway will not focus on the menu (you have to hover the mouse on rofi, for rofi to grab your input).

Known issues

Using i3-dmenu-desktop

i3-dmenu-desktop is not usable directly from sway, but a patch is available here. Unfortunately, the patch cannot be merged because it breaks when used from i3 in some corner cases. See [1] for more information.

You can still apply the patch manually through installing sway-dmenu-desktopAUR[broken link: package not found]. This creates a new binary called sway-dmenu-desktop to be using within sway.

An alternative is to use j4-dmenu-desktopAUR, which is advertised as faster than i3-dmenu-desktop.

To work around this problem, you may try attaching to the first available sway socket, and retrying your command:

$ export SWAYSOCK=$(ls /run/user/*/sway-ipc.*.sock | head -n 1)

To avoid this error, run the command outside of a multiplexer.

Incorrect Monitor Resolution

Config options such as output "HDMI-A-1" res 1280x1024 may not successfully change the resolution. The compositor wlc is responsible for setting the resolution, and attempts to figure out monitor resolution from the TTY.

You may be able to alter your TTY resolution (thus also altering the WLC and Sway resolution) by passing a kernel parameter such as video=HDMI-A-1:1280x1024:e or with with custom edid binaries (see Kernel Mode Setting).