Chapter 6 - Install and configure Sway¶
In this chapter, you will install and configure Sway, a tiling Wayland compositor. Sway will allow to create workspaces and to display applications on the screen. These applications will start on the workspaces that you will configure.
Steps¶
Install Sway and its dependencies¶
Sway is a tiling Wayland compositor.
Wofi is a applications launcher for Wayland.
Foot is a terminal emulator for Wayland.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Create the Sway configuration files¶
Start by creating the configuration directory for Sway.
On the Raspberry Pi, execute the following command(s). | |
---|---|
The following Sway configuration file is based on the default configuration available in /etc/sway/config
. It has been modified and simplified to make it easier to understand.
Take some time to read the file and to understand what each line does.
On the Raspberry Pi, execute the following command(s). | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
Set the keyboard layout. Replace the <layout>
and <variant>
placeholders with the layout and variant that you want to use from previous chapter Chapter 5 - Configure the operating system.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Create the Wofi configuration files¶
Start by creating the configuration directory for Wofi.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Take some time to read the file and to understand what each line does of the following Wofi configuration file.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Create the Foot configuration file¶
Start by creating the configuration directory for Foot.
On the Raspberry Pi, execute the following command(s). | |
---|---|
The following Foot configuration file is based on the default configuration available in /usr/share/foot/foot.ini
. It has been modified and simplified to make it easier to understand.
Take some time to read the comments and to understand what each line does of the following Wofi configuration file.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Check the results¶
For the next step, the command must be executed directly on a Raspberry Pi connected to a screen and a keyboard. The command will start Sway and you will be able to test it.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Sway should start.
Open a terminal¶
To open a terminal, press Win+Enter. Foot should open.
To close Foot, press Win+Shift+Q.
Open the application launcher¶
To open the application launcher, press Win+D. Wofi should open.
Select Foot from the list and press Enter to open it.
To close Foot, press Win+Shift+Q.
Navigate between two terminals¶
Open two terminals by pressing Win+Enter twice. Two Foot terminals should open side by side.
Use the Win+Left and Win+Right shortcuts to navigate between the two terminals.
Move terminals¶
Open two terminals by pressing Win+Enter twice. Two Foot terminals should open side by side.
Use the Win+Shift+Left and Win+Shift+Right shortcuts to navigate between the two terminals.
Open terminals vertically and horizontally¶
Press Win+V to set the split orientation to vertical.
Open a new terminal with Win+Enter. It should open under the current terminal.
Press Win+H to set the split orientation back to horizontal.
Open a new terminal with Win+Enter. It should open to the right of the last terminal.
Switch between workspaces¶
Press Win+2 to switch to the second workspace. You can have up to 10 workspaces as from the Sway configuration file.
See the other workspaces with Win+workspace number.
Switch back to the first workspace with Win+1.
Send an application to a specific workspace¶
Select one of the Foot terminal.
Send it to the second workspace with Win+Shift+2.
Switch to the second workspace with Win+2.
You should see the terminal.
Switch back to the first workspace with Win+Shift+1.
Resize an application¶
When two applications are open side by side, you can resize them.
Enter the resize mod with Win+R.
Resize the application with Left, Right, Up or Down.
Exit the resize mod with Esc.
Reload the Sway configuration file¶
If you ever edit the Sway configuration file, you can reload it with Win+Shift+C.
Close Sway¶
To close Sway, press Win+Shift+E and confirm the message dialog with the mouse.
Start Sway on boot if network is available and attached to a screen¶
First, enable autologin on boot. Replace <username>
with the username of the user you want to autologin.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Then, start Sway when the user logs in on default terminal with the help of the ~/.profile
file.
On the Raspberry Pi, execute the following command(s). | |
---|---|
Summary¶
Congrats! You have successfully configured Sway, Wofi and Foot. You have a lightweight and fast graphical environment that you can use on your Raspberry Pi to squeeze the last drop of performance out of it.
Sway will automatically start on boot if the Raspberry Pi is connected to a screen.
Question
Why do you have to use Sway? Could't we use a more conventional graphical environment like XFCE, LXDE, Gnome or KDE?
Sway is a tiling window manager that manages your applications in a grid. It means it can automatically open applications side by side, vertically or horizontally, using the maximum of the available space. Getting used to it can take a bit of time but it will be very useful in the next chapters to open the BeeScreens applications in a browser assigned to a specific workspace, in full screen and automatically resized to the maximum of the available space.
It is also very efficient and fast, based on Wayland which is a more modern and lightweight graphical protocol than X11.