aboutsummaryrefslogtreecommitdiff
path: root/content/blog/2022-12-23-alpine-desktop.org
blob: 978405d0dfe36dd9281c36a30791c7877451a0d4 (plain) (blame)
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#+date:        <2022-12-23 Fri 00:00:00>
#+title:       How to Set Up Alpine Linux as a Desktop OS with Sway
#+description: Stepwise procedures for installing and setting up Alpine Linux as a desktop operating system, including window manager setup and relevant system adjustments.
#+slug:        alpine-desktop
#+filetags:    :alpine:desktop:linux:

* Isn't Alpine Linux for Servers?

This is a question I see a lot when people are presented with an example
of Alpine Linux running as a desktop OS.

While Alpine is small, fast, and minimal, that doesn't stop it from
functioning at a productive level for desktop users.

This post is documentation of how I installed and modified Alpine Linux
to become my daily desktop OS.

* Installation

Note that I cover the installation of Alpine Linux in my other post, so
I won't repeat it here: [[../alpine-linux/][Alpine Linux: My New Server
OS]].

Basically, get a bootable USB or whatever you prefer with Alpine on it,
boot the ISO, and run the setup script.

#+begin_src sh
setup-alpine
#+end_src

Once you have gone through all the options and installer finishes
without errors, reboot.

#+begin_src sh
reboot
#+end_src

* Initial Setup

Once Alpine is installed and the machine has rebooted, login is as root
initially or =su= to root once you log in as your user. From here, you
should start by updating and upgrading the system in case the ISO was
not fully up-to-date.

#+begin_src sh
# Update and upgrade system
apk -U update && apk -U upgrade

# Add an editor so we can enable the community repository
apk add nano
#+end_src

You need to uncomment the =community= repository for your version of
Alpine Linux.

For v3.17, the =repositories= file should look like this:

#+begin_src sh
nano /etc/apk/repositories
#+end_src

#+begin_src conf
#/media/sda/apks
http://mirrors.gigenet.com/alpinelinux/v3.17/main
http://mirrors.gigenet.com/alpinelinux/v3.17/community
#http://mirrors.gigenet.com/alpinelinux/edge/main
#http://mirrors.gigenet.com/alpinelinux/edge/community
#http://mirrors.gigenet.com/alpinelinux/edge/testing
#+end_src

#+begin_src sh
# Add the rest of your packages
apk add linux-firmware iwd doas git curl wget

# Add yourself to the wheel group so you can use the doas command
adduser $USER wheel
#+end_src

* Window Manager (Desktop)

The [[https://wiki.alpinelinux.org/wiki/Sway][Sway installation guide]]
has everything you need to get Sway working on Alpine.

However, I'll include a brief list of the commands I ran and their
purpose for posterity here.

#+begin_src sh
# Add eudev and set it up
apk add eudev
setup-devd udev

# Since I have Radeon graphics, I need the following packages
apk add mesa-dri-gallium mesa-va-gallium

# Add user to applicable groups
adduser $USER input
adduser $USER video

# Add a font package
apk add ttf-dejavu

# Add the seatd daemon
apk add seatd
rc-update add seatd
rc-service seatd start

# Add user to seat group
adduser $USER seat

# Add elogind
apk add elogind polkit-elogind
rc-update add elogind
rc-service elogind start

# Finally, add sway and dependencies
apk add sway sway-doc
apk add                \ # Install optional dependencies:
    xwayland             \ # recommended for compatibility reasons
    foot                 \ # default terminal emulator
    bemenu               \ # wayland menu
    swaylock swaylockd   \ # lockscreen tool
    swaybg               \ # wallpaper daemon
    swayidle               # idle management (DPMS) daemon
#+end_src

Once you have the packages installed and set-up, you need to export the
=XDG_RUNTIME_DIR= upon login. To do this, edit your =.profile= file.

If you use another shell, such as =zsh=, you need to edit that shell's
profile (e.g., =~/.zprofile=)!

#+begin_src sh
nano ~/.profile
#+end_src

Within the file, paste this:

#+begin_src sh
if test -z "${XDG_RUNTIME_DIR}"; then
  export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir
  if ! test -d "${XDG_RUNTIME_DIR}"; then
    mkdir "${XDG_RUNTIME_DIR}"
    chmod 0700 "${XDG_RUNTIME_DIR}"
  fi
fi
#+end_src

Once that's complete, you can launch Sway manually.

#+begin_src sh
dbus-run-session -- sway
#+end_src

** Personal Touches

I also added the following packages, per my personal preferences and
situation.

#+begin_src sh
doas apk add brightnessctl   \ # Brightness controller
             zsh             \ # Shell
             firefox         \ # Browser
             syncthing       \ # File sync service
             wireguard-tools \ # Wireguard VPN
             gomuks          \ # CLI Matrix client
             neomutt         \ # CLI email client
             thunderbird     \ # GUI email client
             gnupg             # GPG key manager
#+end_src

From here, I use my Syncthing storage to pull all the configuration files I
stored from prior desktops, such as my [[https://git.sr.ht/~cxc/dotfiles][dotfiles]].

* Resolving Issues

** WiFi Issues

I initially tried to set up my Wi-Fi the standard way with =iwd=, but it
didn't work.

Here is what I initially tried (I did all of this as =root=):

#+begin_src sh
apk add iwd
rc-service iwd start
iwctl station wlan0 connect <SSID> # This will prompt for the password
rc-update add iwd boot && rc-update add dbus boot
#+end_src

Then, I added the Wi-Fi entry to the bottom of the networking interface
file:

#+begin_src sh
nano /etc/network/interfaces
#+end_src

#+begin_src conf
auto wlan0
iface wlan0 inet dhcp
#+end_src

Finally, restart the networking service:

#+begin_src sh
rc-service networking restart
#+end_src

My Wi-Fi interface would receive an IP address from the router, but it
could not ping anything in the network. To solve the Wi-Fi issues, I
originally upgraded to Alpine's =edge= repositories, which was
unnecessary.

Really, the solution was to enable the =NameResolvingService=resolvconf=
in =/etc/iwd/main.conf=.

#+begin_src sh
doas nano /etc/iwd/main.conf
#+end_src

#+begin_src conf
[Network]

NameResolvingService=resolvconf
#+end_src

Once I finished this process, my Wi-Fi is working flawlessly.

** Sound Issues

Same as with the Wi-Fi, I had no sound and could not control the
mute/unmute or volume buttons on my laptop.

To resolve this, I installed
[[https://wiki.alpinelinux.org/wiki/PipeWire][pipewire]].

#+begin_src sh
# Add your user to the following groups
addgroup $USER audio
addgroup $USER video

# Install pipewire and other useful packages
apk add pipewire wireplumber pipewire-pulse pipewire-jack pipewire-alsa
#+end_src

Finally, I needed to add =/usr/libexec/pipewire-launcher= to my
=.config/sway/config= file so that Pipewire would run every time I
launched sway.

#+begin_src sh
nano ~/.config/sway/config
#+end_src

#+begin_src conf
# Run pipewire audio server
exec /usr/libexec/pipewire-launcher

# Example audio button controls
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +5%
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -5%
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle
#+end_src

Note that I do not use bluetooth or screen sharing, so I won't cover
those options in this post.

Other than these issues, I have a working Alpine desktop. No other
complaints thus far!