#!/bin/sh
# ============================================================
# Alpine Linux + labwc Desktop Installer
# Wayland / labwc / seatd / greetd / NetworkManager / PipeWire
# ============================================================
echo "=============================================="
echo " Alpine Linux -> labwc Desktop"
echo "=============================================="
echo
# ------------------------------------------------------------
# Check root
# ------------------------------------------------------------
if [ "$(id -u)" != "0" ]; then
echo "ERROR: run this script as root."
exit 1
fi
# ------------------------------------------------------------
# Check Alpine
# ------------------------------------------------------------
if [ ! -f /etc/alpine-release ]; then
echo "ERROR: this script is intended for Alpine Linux."
exit 1
fi
ALPINE_VERSION="$(cut -d'.' -f1,2 /etc/alpine-release)"
echo "Alpine version: $ALPINE_VERSION"
echo
# ------------------------------------------------------------
# Repositories
# ------------------------------------------------------------
echo "➜ Configure Alpine repositories"
cat > /etc/apk/repositories << EOF
https://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/main
https://dl-cdn.alpinelinux.org/alpine/v${ALPINE_VERSION}/community
EOF
apk update
# ------------------------------------------------------------
# Desktop user
# ------------------------------------------------------------
USER="user"
echo "➜ Create desktop user: $USER"
if ! id "$USER" >/dev/null 2>&1; then
adduser -D "$USER"
fi
# sudo
apk add sudo
cat > "/etc/sudoers.d/$USER" << EOF
$USER ALL=(ALL) NOPASSWD: ALL
EOF
chmod 0440 "/etc/sudoers.d/$USER"
echo "✓ User $USER created"
echo
# ------------------------------------------------------------
# Basic desktop infrastructure
# ------------------------------------------------------------
echo "➜ Install desktop infrastructure"
apk add \
dbus \
dbus-x11 \
eudev \
seatd \
seatd-openrc \
polkit \
polkit-elogind \
font-dejavu \
font-noto \
font-noto-cjk
# ------------------------------------------------------------
# User groups
# ------------------------------------------------------------
echo "➜ Configure user groups"
addgroup "$USER" seat 2>/dev/null || true
addgroup "$USER" audio 2>/dev/null || true
addgroup "$USER" video 2>/dev/null || true
addgroup "$USER" input 2>/dev/null || true
# ------------------------------------------------------------
# Wayland / labwc
# ------------------------------------------------------------
echo "★ Install labwc"
apk add \
labwc \
xwayland
# ------------------------------------------------------------
# Useful Wayland desktop applications
# ------------------------------------------------------------
echo "➜ Install Wayland utilities"
apk add \
foot \
rofi \
swaybg \
swayidle \
swaylock \
waybar \
wl-clipboard \
grim \
slurp
# ------------------------------------------------------------
# File manager / removable devices
# ------------------------------------------------------------
echo "➜ Install filesystem / removable device support"
apk add \
gvfs \
gvfs-fuse \
gvfs-smb \
udisks2 \
udisks2-openrc \
fuse-openrc
# ------------------------------------------------------------
# NetworkManager
# ------------------------------------------------------------
echo "➜ Install NetworkManager"
apk add \
networkmanager \
networkmanager-openrc \
networkmanager-tui
rc-update add networkmanager default
# ------------------------------------------------------------
# Seat management
# ------------------------------------------------------------
echo "➜ Configure seatd"
rc-update add seatd default
# ------------------------------------------------------------
# D-Bus
# ------------------------------------------------------------
echo "➜ Configure D-Bus"
rc-update add dbus default
# ------------------------------------------------------------
# PipeWire
# ------------------------------------------------------------
echo "★ Install PipeWire audio"
apk add \
pipewire \
pipewire-pulse \
pipewire-alsa \
pipewire-tools \
pipewire-spa-bluez \
pipewire-pulse-openrc \
wireplumber \
wireplumber-openrc
# ------------------------------------------------------------
# ALSA
# ------------------------------------------------------------
echo "➜ Install ALSA utilities"
apk add \
alsa-utils \
alsaconf \
alsa-lib
addgroup "$USER" audio 2>/dev/null || true
# ------------------------------------------------------------
# Bluetooth
# ------------------------------------------------------------
echo "➜ Install Bluetooth support"
apk add \
bluez \
bluez-openrc \
blueman
rc-update add bluetooth default
# ------------------------------------------------------------
# Login manager
# ------------------------------------------------------------
echo "★ Install greetd"
apk add \
greetd \
greetd-openrc \
greetd-agreety
# ------------------------------------------------------------
# greetd configuration
# ------------------------------------------------------------
echo "➜ Configure greetd"
mkdir -p /etc/greetd
cat > /etc/greetd/config.toml << EOF
[terminal]
vt = 7
[default_session]
command = "agreety --cmd labwc"
user = "greetd"
EOF
# greetd needs access to seatd
addgroup greetd seat 2>/dev/null || true
# Make greetd wait for seatd
if [ -f /etc/conf.d/greetd ]; then
if ! grep -q '^rc_need=".*seatd' /etc/conf.d/greetd 2>/dev/null; then
echo 'rc_need="seatd"' >> /etc/conf.d/greetd
fi
fi
rc-update add greetd default
# ------------------------------------------------------------
# XDG user directories
# ------------------------------------------------------------
echo "➜ Create XDG user directories"
apk add xdg-user-dirs
su - "$USER" -c "xdg-user-dirs-update" 2>/dev/null || true
# ------------------------------------------------------------
# labwc configuration
# ------------------------------------------------------------
echo "➜ Create labwc configuration"
mkdir -p "/home/$USER/.config/labwc"
cat > "/home/$USER/.config/labwc/autostart" << 'EOF'
#!/bin/sh
# D-Bus user session
if command -v dbus-update-activation-environment >/dev/null 2>&1; then
dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
fi
# Wallpaper
if command -v swaybg >/dev/null 2>&1; then
swaybg -c 202020 &
fi
# Panel
if command -v waybar >/dev/null 2>&1; then
waybar &
fi
# NetworkManager tray
if command -v nm-applet >/dev/null 2>&1; then
nm-applet &
fi
# Bluetooth tray
if command -v blueman-applet >/dev/null 2>&1; then
blueman-applet &
fi
EOF
chmod +x "/home/$USER/.config/labwc/autostart"
# ------------------------------------------------------------
# Basic labwc menu
# ------------------------------------------------------------
cat > "/home/$USER/.config/labwc/menu.xml" << 'EOF'
EOF
# ------------------------------------------------------------
# Basic keyboard shortcuts
# ------------------------------------------------------------
cat > "/home/$USER/.config/labwc/rc.xml" << 'EOF'
foot
rofi -show drun
swaylock
EOF
# ------------------------------------------------------------
# Waybar configuration
# ------------------------------------------------------------
mkdir -p "/home/$USER/.config/waybar"
cat > "/home/$USER/.config/waybar/config" << 'EOF'
[
{
"layer": "top",
"position": "top",
"modules-left": [
"wlr/workspaces"
],
"modules-center": [
"clock"
],
"modules-right": [
"network",
"pulseaudio",
"battery"
]
}
]
EOF
cat > "/home/$USER/.config/waybar/style.css" << 'EOF'
* {
border: none;
border-radius: 0;
font-family: sans-serif;
font-size: 13px;
}
window#waybar {
background: rgba(30, 30, 30, 0.95);
color: #ffffff;
}
#workspaces button {
padding: 0 8px;
color: #aaaaaa;
}
#workspaces button.active {
color: #ffffff;
background: #444444;
}
#clock,
#network,
#pulseaudio,
#battery {
padding: 0 10px;
}
EOF
# ------------------------------------------------------------
# Permissions
# ------------------------------------------------------------
echo "➜ Fix user permissions"
chown -R "$USER:$USER" "/home/$USER/.config"
# ------------------------------------------------------------
# Useful software
# ------------------------------------------------------------
echo "★ Install basic software"
apk add \
htop \
neofetch \
curl \
wget \
git \
nano \
less \
file \
unzip \
zip
# ------------------------------------------------------------
# Optional browser
# ------------------------------------------------------------
# Uncomment if required:
#
# apk add firefox
#
# or:
#
# apk add chromium
# ------------------------------------------------------------
# Enable services
# ------------------------------------------------------------
echo "➜ Enable desktop services"
rc-update add dbus default
rc-update add seatd default
rc-update add networkmanager default
rc-update add bluetooth default
rc-update add greetd default
# ------------------------------------------------------------
# Start services when possible
# ------------------------------------------------------------
echo "➜ Start services"
rc-service dbus start 2>/dev/null || true
rc-service seatd start 2>/dev/null || true
rc-service networkmanager start 2>/dev/null || true
rc-service bluetooth start 2>/dev/null || true
# Do NOT start greetd here.
# It will start automatically after reboot.
# ------------------------------------------------------------
# Final information
# ------------------------------------------------------------
echo
echo "=============================================="
echo " ★★★ Alpine + labwc installation complete ★★★"
echo "=============================================="
echo
echo "Desktop user: $USER"
echo
echo "IMPORTANT:"
echo
echo "Set a password for the desktop user:"
echo
echo " passwd $USER"
echo
echo "Then reboot:"
echo
echo " reboot"
echo
echo "After reboot:"
echo
echo " greetd -> labwc"
echo
echo "Wayland compositor : labwc"
echo "Seat manager : seatd"
echo "Login manager : greetd"
echo "Audio : PipeWire + WirePlumber"
echo "Network : NetworkManager"
echo
echo "=============================================="