content/blog/2022-12-23-alpine-desktop.org
268 lines · 7338 bytes
1#+date: <2022-12-23 Fri 00:00:00>
2#+title: Configuring Alpine Linux for Desktop Environment Usage
3#+description: Stepwise procedures for installing and setting up Alpine Linux as a desktop operating system, including window manager setup and relevant system adjustments.
4#+slug: alpine-desktop
5#+filetags: :alpine:desktop:linux:
6
7* Isn't Alpine Linux for Servers?
8
9This is a question I see a lot when people are presented with an example
10of Alpine Linux running as a desktop OS.
11
12While Alpine is small, fast, and minimal, that doesn't stop it from
13functioning at a productive level for desktop users.
14
15This post is documentation of how I installed and modified Alpine Linux
16to become my daily desktop OS.
17
18* Installation
19
20Note that I cover the installation of Alpine Linux in my other post, so
21I won't repeat it here: [[../alpine-linux/][Alpine Linux: My New Server
22OS]].
23
24Basically, get a bootable USB or whatever you prefer with Alpine on it,
25boot the ISO, and run the setup script.
26
27#+begin_src sh
28setup-alpine
29#+end_src
30
31Once you have gone through all the options and installer finishes
32without errors, reboot.
33
34#+begin_src sh
35reboot
36#+end_src
37
38* Initial Setup
39
40Once Alpine is installed and the machine has rebooted, login is as root
41initially or =su= to root once you log in as your user. From here, you
42should start by updating and upgrading the system in case the ISO was
43not fully up-to-date.
44
45#+begin_src sh
46# Update and upgrade system
47apk -U update && apk -U upgrade
48
49# Add an editor so we can enable the community repository
50apk add nano
51#+end_src
52
53You need to uncomment the =community= repository for your version of
54Alpine Linux.
55
56For v3.17, the =repositories= file should look like this:
57
58#+begin_src sh
59nano /etc/apk/repositories
60#+end_src
61
62#+begin_src conf
63#/media/sda/apks
64http://mirrors.gigenet.com/alpinelinux/v3.17/main
65http://mirrors.gigenet.com/alpinelinux/v3.17/community
66#http://mirrors.gigenet.com/alpinelinux/edge/main
67#http://mirrors.gigenet.com/alpinelinux/edge/community
68#http://mirrors.gigenet.com/alpinelinux/edge/testing
69#+end_src
70
71#+begin_src sh
72# Add the rest of your packages
73apk add linux-firmware iwd doas git curl wget
74
75# Add yourself to the wheel group so you can use the doas command
76adduser $USER wheel
77#+end_src
78
79* Window Manager (Desktop)
80
81The [[https://wiki.alpinelinux.org/wiki/Sway][Sway installation guide]]
82has everything you need to get Sway working on Alpine.
83
84However, I'll include a brief list of the commands I ran and their
85purpose for posterity here.
86
87#+begin_src sh
88# Add eudev and set it up
89apk add eudev
90setup-devd udev
91
92# Since I have Radeon graphics, I need the following packages
93apk add mesa-dri-gallium mesa-va-gallium
94
95# Add user to applicable groups
96adduser $USER input
97adduser $USER video
98
99# Add a font package
100apk add ttf-dejavu
101
102# Add the seatd daemon
103apk add seatd
104rc-update add seatd
105rc-service seatd start
106
107# Add user to seat group
108adduser $USER seat
109
110# Add elogind
111apk add elogind polkit-elogind
112rc-update add elogind
113rc-service elogind start
114
115# Finally, add sway and dependencies
116apk add sway sway-doc
117apk add \ # Install optional dependencies:
118 xwayland \ # recommended for compatibility reasons
119 foot \ # default terminal emulator
120 bemenu \ # wayland menu
121 swaylock swaylockd \ # lockscreen tool
122 swaybg \ # wallpaper daemon
123 swayidle # idle management (DPMS) daemon
124#+end_src
125
126Once you have the packages installed and set-up, you need to export the
127=XDG_RUNTIME_DIR= upon login. To do this, edit your =.profile= file.
128
129If you use another shell, such as =zsh=, you need to edit that shell's
130profile (e.g., =~/.zprofile=)!
131
132#+begin_src sh
133nano ~/.profile
134#+end_src
135
136Within the file, paste this:
137
138#+begin_src sh
139if test -z "${XDG_RUNTIME_DIR}"; then
140 export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir
141 if ! test -d "${XDG_RUNTIME_DIR}"; then
142 mkdir "${XDG_RUNTIME_DIR}"
143 chmod 0700 "${XDG_RUNTIME_DIR}"
144 fi
145fi
146#+end_src
147
148Once that's complete, you can launch Sway manually.
149
150#+begin_src sh
151dbus-run-session -- sway
152#+end_src
153
154** Personal Touches
155
156I also added the following packages, per my personal preferences and
157situation.
158
159#+begin_src sh
160doas apk add brightnessctl \ # Brightness controller
161 zsh \ # Shell
162 firefox \ # Browser
163 syncthing \ # File sync service
164 wireguard-tools \ # Wireguard VPN
165 gomuks \ # CLI Matrix client
166 neomutt \ # CLI email client
167 thunderbird \ # GUI email client
168 gnupg # GPG key manager
169#+end_src
170
171From here, I use my Syncthing storage to pull all the configuration files I
172stored from prior desktops, such as my [[https://github.com/ccleberg/dotfiles][dotfiles]].
173
174* Resolving Issues
175
176** WiFi Issues
177
178I initially tried to set up my Wi-Fi the standard way with =iwd=, but it
179didn't work.
180
181Here is what I initially tried (I did all of this as =root=):
182
183#+begin_src sh
184apk add iwd
185rc-service iwd start
186iwctl station wlan0 connect <SSID> # This will prompt for the password
187rc-update add iwd boot && rc-update add dbus boot
188#+end_src
189
190Then, I added the Wi-Fi entry to the bottom of the networking interface
191file:
192
193#+begin_src sh
194nano /etc/network/interfaces
195#+end_src
196
197#+begin_src conf
198auto wlan0
199iface wlan0 inet dhcp
200#+end_src
201
202Finally, restart the networking service:
203
204#+begin_src sh
205rc-service networking restart
206#+end_src
207
208My Wi-Fi interface would receive an IP address from the router, but it
209could not ping anything in the network. To solve the Wi-Fi issues, I
210originally upgraded to Alpine's =edge= repositories, which was
211unnecessary.
212
213Really, the solution was to enable the =NameResolvingService=resolvconf=
214in =/etc/iwd/main.conf=.
215
216#+begin_src sh
217doas nano /etc/iwd/main.conf
218#+end_src
219
220#+begin_src conf
221[Network]
222
223NameResolvingService=resolvconf
224#+end_src
225
226Once I finished this process, my Wi-Fi is working flawlessly.
227
228** Sound Issues
229
230Same as with the Wi-Fi, I had no sound and could not control the
231mute/unmute or volume buttons on my laptop.
232
233To resolve this, I installed
234[[https://wiki.alpinelinux.org/wiki/PipeWire][pipewire]].
235
236#+begin_src sh
237# Add your user to the following groups
238addgroup $USER audio
239addgroup $USER video
240
241# Install pipewire and other useful packages
242apk add pipewire wireplumber pipewire-pulse pipewire-jack pipewire-alsa
243#+end_src
244
245Finally, I needed to add =/usr/libexec/pipewire-launcher= to my
246=.config/sway/config= file so that Pipewire would run every time I
247launched sway.
248
249#+begin_src sh
250nano ~/.config/sway/config
251#+end_src
252
253#+begin_src conf
254# Run pipewire audio server
255exec /usr/libexec/pipewire-launcher
256
257# Example audio button controls
258bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5%
259bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5%
260bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle
261bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle
262#+end_src
263
264Note that I do not use bluetooth or screen sharing, so I won't cover
265those options in this post.
266
267Other than these issues, I have a working Alpine desktop. No other
268complaints thus far!