Skip to content

Sway

Docs / resources

(Awesome) lists:

Other resources:

Installation guides

Distributions

Issues

Installation

sudo apt install sway

Login managers

Setup GDM:

sudo cp /home/varac/.config/sway/gdm/sway.desktop /usr/share/wayland-sessions/

Configuration

Environment variables

From What's the current most effective way of setting env variables in Sway?:

greetd + tuigreet

  • Default in Manjaro-sway

If you're using greetd, use wrapper scripts to set the environment variables in /etc/greetd/

From tuigreet: desktop-environments:

greetd only accepts environment-less commands to be used to start a session. Therefore, if your desktop environment requires either arguments or environment variables, you will need to create a wrapper script and refer to it in an appropriate desktop file.

Without greetd

If you're not using greetd or any other display manager, set the environment variables in ~/.bash_profile, ~/.profile, or ~/.config/fish/ depending on your login shell.

With sway as systemd user service

If you're running sway as a systemd service or if you're running systemd user services that are built for Wayland, you'll have to set specific environment variables in ~/.config/environment.d/.

Etc

How to tell if I'm on wayland ?

echo $XDG_SESSION_TYPE

swaymsg

Get all outputs (swaymsg pretty-prints to stdout but when piped, it prints json):

swaymsg -t get_outputs

Get currently focused output:

swaymsg -t get_outputs| jq -r '.[] | select(.focused ).name

Set output resolution:

sway output HDMI-A-1 mode 1024x768

Show all active windows/clients:

swaymsg -t get_tree | jq '.nodes[]'

Show all windows/clients on output LVDS-1:

swaymsg -t get_tree | jq '.nodes[] | select(.name=="LVDS-1")'

Show all windows/clients on workspace 10:

swaymsg -t get_tree | jq '.nodes[].nodes[] | \
  select(.name | test("10")).nodes[] | {name,id,pid}'

Show all floating windows:

swaymsg -t get_tree | jq '.nodes[].nodes[].floating_nodes[]'

Show current config before includes, see feature request: alternative to swaymsg -t get_config that is a parsed JSON structure;

swaymsg -t get_config

Show current config after includes (custom alias):

sway_config

Xwayland

Let non-wayland-native apps (i.e. chromium) run under wayland.

Use xprop or xwininfo in a terminal and try clicking on the window (or xeyes). xlsclients shows the currently running apps which use xwayland.

Or use swaymsg -t get_tree | grep class

I.e., current non-native-wayland apps:

  • signal-desktop

Run application as root in Wayland

xhost +SI:localuser:root
gksudo -k gparted

Screen sharing

Autostart in sway

Sway doesn't support the XDG Desktop Application Autostart Specification (~/.config/autostart/) out of the box. dex comes to the rescue, but it's stalled (last commit 2022-02). It can be used as shown in this example. The preferred way for autostarting applications in sway is to exec them from sway config. The Systemd integration can also be used to run apps as systemd service.

Projects to try out

  • swaysome This binary helps you configure sway to work a bit more like Awesome. This currently means workspaces that are name-spaced on a per-screen basis.
  • sworkstyle Workspaces with the swayest style! This program will dynamically rename your workspaces to indicate which programs are running in each workspace (Seems similar to what nwg-panel already does)
  • persway