Sway on Laptop: Difference between revisions

From Alpine Linux
(fixed)
(sway)
Line 1: Line 1:
Quq's guide for installing Alpine with Sway, for latitude 7370.
Install and configure Sway


Download Alpine Linux, verify checksum then
== Install Graphics Drivers ==


  dd if=alpine-extended.iso of=/dev/sdb
Graphics drivers:


Known issues: screen sharing appears to be broken.
* [[Intel Video]]
* [[Radeon Video]]
* [[Nvidia Video]]


More details forth-coming.
== Add a normal user ==


Press <code>f12</code> at boot to enter Setup, wipe disk under Maintenance>Data Wipe. Check Wipe on Next Boot check box. Exit.
Use <code>setup-user</code> to add a non-system normal user for running Sway.


Plug in external storage device with alpine extended on it. Let it boot.
== Install seatd ==


Login as rootThere is no password.
Install seatd, a minimal seat management daemonThis grants the required permissions to the user running sway:


Set up internet connection
apk add seatd
# add seatd to boot run-level, because greetd requires it to be running
rc-update add seatd boot
rc-service seatd start
adduser $USER seat


  # -r is needed for starting the network after configuration
== Install elogind (optional) ==
  setup-interfaces -r


  Initialize: wlan0
elogind is used to enable suspend-to-RAM with swayidle:
  Enter SSID: my net
  Password, DHCP.


Set up SSH server:
apk add elogind
rc-update add elogind
rc-service elogind start


  setup-sshd
== Set up eudev ==
  # example:
  ssh server:        openssh
  allow root:        "prohibit-password" or "yes"
  ssh key:          "none" or "<public key>"


Configurations set here will be copied verbatim to the installed system.
[[eudev]] is recommended and required for the greeter. Or else it will not be able to find any input device (libinput failure).


Set root password or /root/.ssh/authorized_keys.
setup-devd udev
Choose a strong root password, as it will be copied to the installed system. However, authorized_keys is not copied.


Set up time:
== Install greetd (optional) ==


  setup-ntp chrony
greetd is used to set [[Wayland#XDG_RUNTIME_DIR|XDG_RUNTIME_DIR]] and properly configure seat:


Set up repos:
apk add greetd greetd-gtkgreet cage greetd-openrc
rc-update add greetd
adduser greetd seat


  setup-apkrepos -c
In <code>/etc/greetd/config.toml</code>, set
  # show mirror list, then select geographically nearest mirror
  # -c argument enables community repo


Install encrypted:
<pre>
[default_session]


  setup-disk -v -e -m sys -k edge -s 0 /dev/sda
command = "cage -s -- gtkgreet"
</pre>


Exit chroot and power off:
In <code>/etc/greetd/environments</code>, set
<pre>
# Launch Sway with a D-Bus server available, use:
dbus-run-session -- sway
</pre>


   exit
Running sway with DBus is needed for PipeWire and screen sharing.
  poweroff
 
== Install doas ==
Doas is used to grant permissions for suspend-to-RAM and brightness control with brightnessctl:
 
apk add doas brightnessctl
# optionally, allow $USER root access with password
adduser $USER wheel
 
In <code>/etc/doas.conf</code>, set
 
permit :wheel
permit nopass $USER as root cmd /bin/loginctl
permit nopass $USER as root cmd /usr/bin/brightnessctl
 
After setting the above, suspend-to-RAM can be triggered by running <code>/bin/loginctl suspend</code> (use full path to executable) and brightness can be adjusted by running <code>/usr/bin/brightnessctl set 100</code>.
 
== Install fonts ==
 
Install DejaVu fonts, which has good Unicode coverage:
 
apk add font-dejavu
 
== Install PipeWire, WirePlumber and XDG portals ==
 
For a reasonable desktop experience with support for audio and screensharing, install pipewire, wireplumber and xdg portals:
 
apk add pipewire pipewire-pulse pipewire-tools
apk add wireplumber
apk add xdg-desktop-portal xdg-desktop-portal-wlr
 
Later, we need to launch PipeWire with Sway and configure several environment variables.
 
== Install Sway ==
 
apk add sway \
    xwayland            \ # if you need xserver
    foot                \ # default terminal emulator. Modify $term in config for a different one.
    bemenu              \ # wayland native menu for choosing program and screensharing monitor
    swaylock swaylockd   \ # lockscreen tool
    grim                \ # screenshot tool
    wl-clipboard        \ # clipboard management
    i3status            \ # simple status bar
    swayidle              # idle management (DPMS) daemon
 
== Sway configuration ==
 
Copy default sway configuration to <code>~/.config</code>:
 
# as normal user
mkdir -p ~/.config/sway
cp /etc/sway/config ~/.config/sway/
 
Launch PipeWire with Sway, add the following to sway config:
 
exec /usr/libexec/pipewire-launcher
 
You also need to set DBus variables for the portal and screensharing features to work:
 
exec dbus-update-activation-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
 
Replace dmenu (depends on X server) with bemenu (Wayland native):
 
set $menu dmenu_path | bemenu | xargs swaymsg exec --
 
Set a mouse cursor, using GNOME Adwaita theme:
 
seat "*" xcursor_theme Adwaita 16
 
Set screen lock and suspend-to-RAM:
 
exec swayidle -w \
          timeout 300 'swaylock --daemonize' \
          timeout 330 'doas /bin/loginctl suspend' \
          before-sleep 'swaylock --daemonize'
 
Do not lock the screen if program is running in full screen:
 
for_window [app_id="^.*"] inhibit_idle fullscreen

Revision as of 22:53, 19 February 2024

Install and configure Sway

Install Graphics Drivers

Graphics drivers:

Add a normal user

Use setup-user to add a non-system normal user for running Sway.

Install seatd

Install seatd, a minimal seat management daemon. This grants the required permissions to the user running sway:

apk add seatd
# add seatd to boot run-level, because greetd requires it to be running
rc-update add seatd boot
rc-service seatd start
adduser $USER seat

Install elogind (optional)

elogind is used to enable suspend-to-RAM with swayidle:

apk add elogind
rc-update add elogind
rc-service elogind start

Set up eudev

eudev is recommended and required for the greeter. Or else it will not be able to find any input device (libinput failure).

setup-devd udev

Install greetd (optional)

greetd is used to set XDG_RUNTIME_DIR and properly configure seat:

apk add greetd greetd-gtkgreet cage greetd-openrc
rc-update add greetd
adduser greetd seat

In /etc/greetd/config.toml, set

[default_session]

command = "cage -s -- gtkgreet"

In /etc/greetd/environments, set

# Launch Sway with a D-Bus server available, use:
dbus-run-session -- sway

Running sway with DBus is needed for PipeWire and screen sharing.

Install doas

Doas is used to grant permissions for suspend-to-RAM and brightness control with brightnessctl:

apk add doas brightnessctl
# optionally, allow $USER root access with password
adduser $USER wheel

In /etc/doas.conf, set

permit :wheel
permit nopass $USER as root cmd /bin/loginctl
permit nopass $USER as root cmd /usr/bin/brightnessctl

After setting the above, suspend-to-RAM can be triggered by running /bin/loginctl suspend (use full path to executable) and brightness can be adjusted by running /usr/bin/brightnessctl set 100.

Install fonts

Install DejaVu fonts, which has good Unicode coverage:

apk add font-dejavu

Install PipeWire, WirePlumber and XDG portals

For a reasonable desktop experience with support for audio and screensharing, install pipewire, wireplumber and xdg portals:

apk add pipewire pipewire-pulse pipewire-tools
apk add wireplumber
apk add xdg-desktop-portal xdg-desktop-portal-wlr

Later, we need to launch PipeWire with Sway and configure several environment variables.

Install Sway

apk add sway \
   xwayland             \ # if you need xserver
   foot                 \ # default terminal emulator. Modify $term in config for a different one.
   bemenu               \ # wayland native menu for choosing program and screensharing monitor
   swaylock swaylockd   \ # lockscreen tool
   grim                 \ # screenshot tool
   wl-clipboard         \ # clipboard management
   i3status             \ # simple status bar
   swayidle               # idle management (DPMS) daemon

Sway configuration

Copy default sway configuration to ~/.config:

# as normal user
mkdir -p ~/.config/sway
cp /etc/sway/config ~/.config/sway/

Launch PipeWire with Sway, add the following to sway config:

exec /usr/libexec/pipewire-launcher

You also need to set DBus variables for the portal and screensharing features to work:

exec dbus-update-activation-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway

Replace dmenu (depends on X server) with bemenu (Wayland native):

set $menu dmenu_path | bemenu | xargs swaymsg exec --

Set a mouse cursor, using GNOME Adwaita theme:

seat "*" xcursor_theme Adwaita 16

Set screen lock and suspend-to-RAM:

exec swayidle -w \
         timeout 300 'swaylock --daemonize' \
         timeout 330 'doas /bin/loginctl suspend' \
         before-sleep 'swaylock --daemonize'

Do not lock the screen if program is running in full screen:

for_window [app_id="^.*"] inhibit_idle fullscreen