Sway: Difference between revisions

From Alpine Linux
No edit summary
Line 15: Line 15:
# apk add mesa-dri-gallium  # gallium
# apk add mesa-dri-gallium  # gallium
# apk add mesa-dri-classic  # or classic
# apk add mesa-dri-classic  # or classic
# apk add mesa-dri-nouveau  # for nvidia users
</pre>
</pre>


Line 94: Line 95:
== Running Sway ==
== Running Sway ==


{{Note|
To run sway, first set XDG_RUNTIME_DIR to a suitable location (e.g. create a .run folder in your home directory and set it to ~/.run). Then run sway from the Linux console (dbus-launch is used because pipewire needs it, it is included in dbus-x11 and you may omit it):
Skip setting XDG_RUNTIME_DIR if you are using elogind }}
 
<pre>
$ XDG_RUNTIME_DIR=~/.run dbus-launch sway
</pre>


To run sway, first set XDG_RUNTIME_DIR to a suitable location (e.g. /tmp). Install & configure elogind to skip this step. Then run sway from the Linux console:
(if you run sway with seatd-launch, you will need to use <code>$ XDG_RUNTIME_DIR=~/.run dbus-launch seatd-launch sway</code>)


You can also create a simple alias in your shell rc file (e.g. .zshrc), like:
<pre>
<pre>
$ XDG_RUNTIME_DIR=/tmp sway
alias swayinit="XDG_RUNTIME_DIR=~/.run dbus-launch seatd-launch sway"
</pre>
</pre>
(if you run sway with seatd-launch, you will need to use <code>$ XDG_RUNTIME_DIR=/tmp seatd-launch sway</code>)


See the [https://wiki.alpinelinux.org/wiki/Wayland Wayland] page for a permanent configuration
See the [https://wiki.alpinelinux.org/wiki/Wayland Wayland] page for a permanent configuration
Line 114: Line 117:


An example config is provided at <code>/etc/sway/config</code>. Copy it to <code>~/.config/sway/config</code> and read through it to learn the default keybindings.
An example config is provided at <code>/etc/sway/config</code>. Copy it to <code>~/.config/sway/config</code> and read through it to learn the default keybindings.
You might want to have gaps between windows, in which case add:
<pre>
inner_gaps 20
outer_gaps 20
</pre>
(replace 20 with the amount of pixels you want to be used for gaps) in your sway config.
You might have two monitors, and you might want to set their position, so here's an example of how to do it:
<pre>
output eDP-1 mode 1920x1080@60Hz
output eDP-1 position 1920,0
output DP-1 position 0,0
output DP-1 mode 1920x1080@120Hz
</pre>
In this case, eDP-1 is the internal laptop monitor running at 60Hz and DP-1 is the external monitor running at 120Hz. The position of the laptop monitor is where the external monitor's width ends, so if the display is 1920 pixels wide and it is on the left, the laptop's monitor would be on the right, so it's width would start at the end of the second monitor's width, so at 1920. Replace the eDP-1 and DP-1 outputs with your own ones, and to change resolution and refresh rate, change the mode according to your parameters.


For additional information, start at <code>man 5 sway</code> and read the [https://github.com/swaywm/sway/wiki upstream FAQ].
For additional information, start at <code>man 5 sway</code> and read the [https://github.com/swaywm/sway/wiki upstream FAQ].


[[Category:Desktop]]
[[Category:Desktop]]

Revision as of 21:08, 12 February 2022

Sway is a tiling Wayland compositor. It's a drop-in replacement for the i3 window manager.

Prerequisites

First, install & configure eudev:

# apk add eudev
# setup-udev

Then install graphics drivers appropriate to your system:

# apk add mesa-dri-gallium  # gallium
# apk add mesa-dri-classic  # or classic
# apk add mesa-dri-nouveau  # for nvidia users

The following links contain guides for setting up the video stack.

Add yourself to the input and video groups:

# adduser $USER input
# adduser $USER video

You have to log out and back in for this to take effect.

Install some TTF fonts:

# apk add ttf-dejavu

Since sway 1.6.1 (more specifically, since wlroots 0.14), you need to set up libseat backend if you wish to run sway directly (without nesting it in another wayland compositor). To do that, choose one of the following methods:

Option 1: seatd daemon (recommended)
# apk add seatd
# rc-update add seatd
# rc-service seatd start
# adduser $USER seat

If you are already logged in as a $USER, you will need to relogin.

Option 2: seatd-launch
# apk add seatd-launch

When starting sway, you will need to prefix invocation with seatd-launch. Note: seatd-launch is a suid binary, so it might be wise to use one of the other methods from a security perspective.

Option 3: elogind daemon
# apk add elogind polkit-elogind
# rc-update add elogind
# rc-service elogind start

Using elogind will automatically set the necessary permissions, so you can skip adding groups like seat and video

Installation

We can now install sway:

# apk add sway sway-doc
# apk add                \ # Install optional dependencies:
    xwayland             \ # recommended for compatibility reasons
    foot                 \ # default terminal emulator
    dmenu                \ # default application launcher
    swaylock             \ # lockscreen tool
    swayidle               # idle management (DPMS) daemon

Running Sway

To run sway, first set XDG_RUNTIME_DIR to a suitable location (e.g. create a .run folder in your home directory and set it to ~/.run). Then run sway from the Linux console (dbus-launch is used because pipewire needs it, it is included in dbus-x11 and you may omit it):

$ XDG_RUNTIME_DIR=~/.run dbus-launch sway

(if you run sway with seatd-launch, you will need to use $ XDG_RUNTIME_DIR=~/.run dbus-launch seatd-launch sway)

You can also create a simple alias in your shell rc file (e.g. .zshrc), like:

alias swayinit="XDG_RUNTIME_DIR=~/.run dbus-launch seatd-launch sway"

See the Wayland page for a permanent configuration

Note:

swaylock needs to be able to read your /etc/shadow file to be able to validate your password

Configuration and Usage

An example config is provided at /etc/sway/config. Copy it to ~/.config/sway/config and read through it to learn the default keybindings.

You might want to have gaps between windows, in which case add:

inner_gaps 20
outer_gaps 20

(replace 20 with the amount of pixels you want to be used for gaps) in your sway config.

You might have two monitors, and you might want to set their position, so here's an example of how to do it:

output eDP-1 mode 1920x1080@60Hz
output eDP-1 position 1920,0
output DP-1 position 0,0
output DP-1 mode 1920x1080@120Hz

In this case, eDP-1 is the internal laptop monitor running at 60Hz and DP-1 is the external monitor running at 120Hz. The position of the laptop monitor is where the external monitor's width ends, so if the display is 1920 pixels wide and it is on the left, the laptop's monitor would be on the right, so it's width would start at the end of the second monitor's width, so at 1920. Replace the eDP-1 and DP-1 outputs with your own ones, and to change resolution and refresh rate, change the mode according to your parameters.

For additional information, start at man 5 sway and read the upstream FAQ.