Skip to content

Instantly share code, notes, and snippets.

@naranyala
Created January 5, 2026 04:57
Show Gist options
  • Select an option

  • Save naranyala/7be54c4a07af1b899199881ce1229281 to your computer and use it in GitHub Desktop.

Select an option

Save naranyala/7be54c4a07af1b899199881ce1229281 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Minimal XFCE desktop setup for Alpine Linux with error handling
set -euo pipefail
# Function to print messages
log() {
echo "[INFO] $*"
}
error_exit() {
echo "[ERROR] $*" >&2
exit 1
}
# Ensure running as root
if [ "$(id -u)" -ne 0 ]; then
error_exit "This script must be run as root (use sudo)."
fi
log "Updating system..."
apk update || error_exit "apk update failed"
apk upgrade || error_exit "apk upgrade failed"
log "Installing Xorg server and drivers..."
apk add --no-cache \
xorg-server \
xf86-video-vesa \
xf86-input-evdev \
mesa-dri-gallium \
mesa-dri-intel \
mesa-dri-nouveau \
mesa-dri-radeon \
dbus || error_exit "Failed to install Xorg components"
log "Installing XFCE core packages..."
apk add --no-cache \
xfce4 \
xfce4-terminal \
thunar || error_exit "Failed to install XFCE packages"
# Optional: lightweight display manager
if apk info slim >/dev/null 2>&1; then
log "Slim already installed"
else
log "Installing Slim display manager..."
apk add --no-cache slim || error_exit "Failed to install Slim"
rc-update add slim || error_exit "Failed to enable Slim"
fi
log "Enabling dbus service..."
rc-update add dbus || error_exit "Failed to enable dbus"
rc-service dbus start || error_exit "Failed to start dbus"
log "Starting Slim (login manager)..."
rc-service slim start || log "Slim failed to start — you can run 'startxfce4' manually"
log "Installation complete!"
echo "Reboot or run 'startxfce4' to launch XFCE."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment