sway

Configuration

The user's sway configuration lives at ~/.config/sway/config.

Use man 5 sway to get the sway configuration manpages.

Display

See the documentation section on display configuration.

Helpful commands, if internet is not available:

man 5 sway-output  # for sway-output configuration man pages
swaymsg -t get_outputs  # get a list of output names

If sway has trouble detecting a hotplugged monitor, try running

echo detect | sudo tee /sys/class/drm/card0-DP-1/status

adapting card0 (GPU) and DP-1 (connector) to your situation, of course.

Key bindings

Taken mostly from this Sway cheatsheet.

MOD refers to the configured modifier key: Typically, it is the Super/Windows key. Alternatively, ALT might be used.

Basics

key binding effect
MOD + RET open new terminal
MOD + h focus left
MOD + j focus down
MOD + k focus up
MOD + l focus right
MOD + a focus parent
MOD + space bar toggle focus mode

Moving windows

key binding effect
MOD + space bar + h move window left
MOD + space bar + j move window down
MOD + space bar + k move window up
MOD + space bar + l move window right

Modifying windows

key binding effect
MOD + f toggle fullscreen
MOD + v split window vertically
MOD + b split window horizontally
MOD + r resize mode

Changing the container layout

key binding effect
MOD + s stacking
MOD + w tabbed
MOD + e default (toggle vertical/horizontal)

Floating

key binding effect
MOD + SHIFT + space bar toggle floating
MOD + left mouse button drag floating

Using workspaces

key binding effect
MOD + [0-9] switch to indicated workspace
MOD + SHIFT + [0-9] move window to indicated workspace

Opening/closing applications

key binding effect
MOD + d open application launcher (dmenu)
MOD + SHIFT + q kill selected window

Restart/exit

key binding effect
MOD + SHIFT + c reload configuration file
MOD + SHIFT + e exit

Taking screenshots

Make sure you have slurp and grim installed, then simply run:

grim -g "$(slurp)"

and select the region you want to screenshot.

Controlling screen brightness

Use brightnessctl.

brightnessctl -l  # list devices
brightnessctl -d <DEVICE_NAME> s +20%  # increase brightness level by 20%
brightnessctl -d <DEVICE_NAME> s 90%   # set brightness level to 90%
brightnessctl -d <DEVICE_NAME> s 25%-  # reduce brightness level by 25%

To use the brightness special keys on you keyboard, bind them to those commands in the sway config like so:

bindsym XF86MonBrightnessDown exec brightnessctl set 5%-
bindsym XF86MonBrightnessUp exec brightnessctl set 5%+

Controlling audio volume

Audio volume is handled by pulseaudio but bindings for the special keys can be setup in the sway config like so:

bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle

To find your way around audio output sinks, use ...

$ pactl list sinks short       # ... to list available output sinks
$ pactl get-default-sink       # ... to find what is the current default sink
$ pactl set-default-sink NAME  # ... to change the default output sink

If an audio output sink is not shown (e.g. a bluetooth speaker), restarting the pulseaudio service might help:

systemctl --user restart pulseaudio.service

For more information on PulseAudio see the Debian and Arch wikis.

Bluetooth

Note

Not a sway topic. Including it here as this is where I'll search for it.

With the alias bt=bluetoothctl:

bt power on/off   # power bluetooth on or off
bt scan on        # scan for devices
bt devices        # list devices
bt pair <MAC_ADDRESS>     # pair with a device (make sure device is in pair mode)
bt trust <MAC_ADDRESS>
bt connect <MAC_ADDRESS>  # connect to device
bt remove <MAC_ADDRESS>   # remove device from paired list

Clipboard interactions

Note

Not strictly a sway but rather a Wayland topic. Including it here as this is where I'll search for it.

To copy/paste to/from the clipboard on Wayland, use wl-clipboard:

# Copy a simple text message:
$ wl-copy Hello world!

# Copy the list of files in ~/Downloads:
$ ls ~/Downloads | wl-copy

# Copy an image:
$ wl-copy < ~/Pictures/photo.png

# Copy the previous command:
$ wl-copy "!!"

# Paste to a file:
$ wl-paste > clipboard.txt

# Sort clipboard contents:
$ wl-paste | sort | wl-copy

# Upload clipboard contents to a pastebin on each change:
$ wl-paste --watch nc paste.example.org 5555

To copy from inside Emacs, mark the selection, hit M - | and run wl-copy.

See also