After installing the desktop dependencies, we can now install a desktop environment. For this tutorial, we'll focus on XFCE, a lightweight yet feature-complete desktop environment that's perfect for a custom Linux distribution.
- Desktop dependencies installed (Chapter 7.5)
- X.Org server configured and working
- Package management system ready (Chapter 7.1-7.4)
- Display manager (optional but recommended)
Pros:
- Lightweight (low resource usage)
- Modular architecture
- Stable and mature
- GTK-based
- Easy to customize
- Good for learning
System Requirements:
- RAM: 512MB minimum, 1GB recommended
- Disk: ~500MB for base installation
LXQt (Even lighter):
- Qt-based
- Very minimal resource usage
- Modern and actively developed
MATE (Traditional):
- GNOME 2 fork
- Familiar interface
- Medium resource usage
Cinnamon (Feature-rich):
- Modern and polished
- Higher resource requirements
- Better for desktop use
graph TD
A[X Server] --> B[Window Manager]
B --> C[Panel/Taskbar]
B --> D[Desktop Manager]
B --> E[Window Decorations]
F[Session Manager] --> B
F --> G[Settings Manager]
F --> H[Application Launcher]
I[File Manager] --> J[Desktop Icons]
K[Terminal Emulator] --> B
L[Application Menu] --> H
# Install XFCE base group
pacman -S --noconfirm \
xfce4 \
xfce4-goodies
# Or install individual components:
pacman -S --noconfirm \
xfwm4 \ # Window manager
xfce4-panel \ # Panel/taskbar
xfce4-session \ # Session manager
xfdesktop \ # Desktop manager
xfce4-settings \ # Settings manager
thunar \ # File manager
xfce4-terminal # Terminal emulator# File manager plugins
pacman -S --noconfirm \
thunar-volman \ # Removable media management
thunar-archive-plugin \
gvfs \ # Virtual filesystem
gvfs-mtp \ # MTP device support
gvfs-gphoto2 # Camera support
# System utilities
pacman -S --noconfirm \
xfce4-taskmanager \ # Task manager
xfce4-power-manager \ # Power management
xfce4-screensaver \ # Screen saver/locker
xfce4-notifyd # Notification daemon
# Panel plugins (optional but useful)
pacman -S --noconfirm \
xfce4-pulseaudio-plugin \
xfce4-battery-plugin \
xfce4-cpufreq-plugin \
xfce4-datetime-plugin \
xfce4-mount-plugin \
xfce4-netload-plugin \
xfce4-systemload-plugin \
xfce4-weather-pluginA display manager provides a graphical login screen:
# LightDM (recommended for XFCE)
pacman -S --noconfirm \
lightdm \
lightdm-gtk-greeter \
lightdm-gtk-greeter-settings
# Enable LightDM service
systemctl enable lightdm.serviceAlternative: SDDM (for Qt-based systems):
pacman -S --noconfirm sddm
systemctl enable sddm.service# PulseAudio (recommended)
pacman -S --noconfirm \
pulseaudio \
pulseaudio-alsa \
pavucontrol \ # GUI mixer
alsa-utils # ALSA utilities
# Enable audio for user
usermod -aG audio <username>pacman -S --noconfirm \
networkmanager \
network-manager-applet \
nm-connection-editor
# Enable NetworkManager
systemctl enable NetworkManager.service
systemctl disable systemd-networkd.service # If previously enabled# Edit LightDM configuration
cat > /etc/lightdm/lightdm.conf << 'EOF'
[Seat:*]
greeter-session=lightdm-gtk-greeter
user-session=xfce
[LightDM]
run-directory=/run/lightdm
[XDMCPServer]
enabled=false
EOF
# Configure greeter theme
cat > /etc/lightdm/lightdm-gtk-greeter.conf << 'EOF'
[greeter]
theme-name=Adwaita
icon-theme-name=Adwaita
font-name=Sans 10
background=/usr/share/backgrounds/xfce/xfce-blue.jpg
position=50%,center 50%,center
EOF# Create default session configuration
mkdir -p /etc/xdg/xfce4
cat > /etc/xdg/xfce4/xinitrc << 'EOF'
#!/bin/sh
# XFCE default startup script
# Start session manager
exec xfce4-session
EOF
chmod +x /etc/xdg/xfce4/xinitrcFor users who don't use a display manager:
# Create ~/.xinitrc for the user
cat > ~/.xinitrc << 'EOF'
#!/bin/sh
# Load X resources
[ -f ~/.Xresources ] && xrdb -merge ~/.Xresources
# Start XFCE
exec startxfce4
EOF
chmod +x ~/.xinitrc# Create mimeapps.list for default applications
mkdir -p ~/.config
cat > ~/.config/mimeapps.list << 'EOF'
[Default Applications]
text/plain=mousepad.desktop
text/html=firefox.desktop
image/png=ristretto.desktop
image/jpeg=ristretto.desktop
application/pdf=atril.desktop
inode/directory=thunar.desktop
[Added Associations]
text/plain=mousepad.desktop;
image/png=ristretto.desktop;
image/jpeg=ristretto.desktop;
EOF# GTK themes
pacman -S --noconfirm \
arc-gtk-theme \
papirus-icon-theme \
adwaita-icon-theme
# Window manager themes
pacman -S --noconfirm \
xfwm4-themes
# Cursors
pacman -S --noconfirm \
xcursor-themes# Set theme via xfconf
xfconf-query -c xsettings -p /Net/ThemeName -s "Arc-Dark"
xfconf-query -c xsettings -p /Net/IconThemeName -s "Papirus-Dark"
xfconf-query -c xfwm4 -p /general/theme -s "Arc-Dark"
# Or use GUI settings manager
xfce4-appearance-settings# Set default fonts
xfconf-query -c xsettings -p /Gtk/FontName -s "DejaVu Sans 10"
xfconf-query -c xsettings -p /Gtk/MonospaceFontName -s "DejaVu Sans Mono 10"
# Enable font antialiasing
xfconf-query -c xsettings -p /Xft/Antialias -s 1
xfconf-query -c xsettings -p /Xft/HintStyle -s "hintslight"
xfconf-query -c xsettings -p /Xft/RGBA -s "rgb"# Text editor
pacman -S --noconfirm mousepad
# Image viewer
pacman -S --noconfirm ristretto
# Archive manager
pacman -S --noconfirm xarchiver
# PDF viewer
pacman -S --noconfirm atril
# Web browser
pacman -S --noconfirm firefox
# Media player
pacman -S --noconfirm vlc
# Screenshot tool
pacman -S --noconfirm xfce4-screenshooter# Code editor
pacman -S --noconfirm \
geany \
geany-plugins
# Terminal tools
pacman -S --noconfirm \
tmux \
htop \
git# The display manager starts automatically on boot
systemctl start lightdm.service
# Check status
systemctl status lightdm.service
# View logs
journalctl -u lightdm.service# Login on console
# Then start X:
startx
# Or start XFCE directly:
startxfce4For development/testing systems:
# Configure auto-login in LightDM
cat > /etc/lightdm/lightdm.conf.d/50-autologin.conf << 'EOF'
[Seat:*]
autologin-user=<username>
autologin-session=xfce
EOF
# Add user to autologin group
groupadd -r autologin
usermod -aG autologin <username># Panel is configured via GUI:
xfce4-panel --preferences
# Or edit configuration files in:
# ~/.config/xfce4/panel/# Desktop settings:
xfdesktop-settings
# Configure background, icons, menu# Open keyboard settings:
xfce4-keyboard-settings
# Common shortcuts to configure:
# - Terminal: Super+T
# - Application finder: Super+Space
# - File manager: Super+E
# - Lock screen: Ctrl+Alt+L# Open window manager tweaks:
xfwm4-tweaks-settings
# Configure:
# - Compositor (for transparency, shadows)
# - Window snapping
# - Focus behavior
# - Workspaces# Create a new user with home directory
useradd -m -G wheel,audio,video,storage -s /bin/bash <username>
passwd <username>
# Configure sudo access
echo "%wheel ALL=(ALL:ALL) ALL" >> /etc/sudoers.d/wheel# Switch users (via display manager)
# Click on username dropdown in LightDM greeter
# Switch users from terminal:
dm-tool switch-to-greeter
# List active sessions:
loginctl list-sessions
# Lock screen:
xflock4# Test window manager
xfwm4 --replace &
# Test panel
xfce4-panel --restart
# Test desktop
xfdesktop --reload
# Test session manager
xfce4-session-settings# List XFCE processes
ps aux | grep xfce
# Check session status
loginctl show-session $XDG_SESSION_ID
# Verify D-Bus
dbus-send --session --print-reply \
--dest=org.freedesktop.DBus \
/org/freedesktop/DBus \
org.freedesktop.DBus.ListNames# Monitor resource usage
xfce4-taskmanager
# Or use htop
htop
# Check memory usage
free -h
# Expected XFCE idle memory: 300-500MBCheck service status:
systemctl status lightdm.service
journalctl -u lightdm.service -bCommon fixes:
# Reconfigure X server
dpkg-reconfigure xserver-xorg # Debian-based
# Check X server works
X :1 &
# Verify display manager installed
pacman -Q lightdmCheck session errors:
cat ~/.xsession-errors
# Or check journal
journalctl --user -bReset XFCE configuration:
# Backup first
mv ~/.config/xfce4 ~/.config/xfce4.backup
# Restart session
xfce4-session-logout --logoutCheck PulseAudio:
# Start PulseAudio
pulseaudio --start
# Check status
pactl info
# Test sound
speaker-test -c 2
# Open mixer
pavucontrolCheck ALSA:
# Unmute audio
alsamixer
# Test with aplay
aplay /usr/share/sounds/alsa/Front_Center.wavCheck NetworkManager:
systemctl status NetworkManager
# Restart if needed
systemctl restart NetworkManager
# Use nmcli
nmcli device status
nmcli connection showDisable compositor:
xfconf-query -c xfwm4 -p /general/use_compositing -s falseDisable animations:
# In Settings > Window Manager Tweaks > Compositor
# Uncheck "Show shadows under dock windows"
# Reduce opacity settingscat > /tmp/PKGBUILD << 'EOF'
pkgname=xfce-desktop-complete
pkgver=1.0
pkgrel=1
pkgdesc="Complete XFCE desktop environment for LFS"
arch=('any')
url="https://www.xfce.org/"
license=('GPL')
depends=(
# Core XFCE
'xfce4'
'xfce4-goodies'
# Display manager
'lightdm'
'lightdm-gtk-greeter'
# Audio
'pulseaudio'
'pavucontrol'
# Network
'networkmanager'
'network-manager-applet'
# Essential apps
'firefox'
'mousepad'
'ristretto'
'xarchiver'
)
optdepends=(
'vlc: Media player'
'gimp: Image editing'
'libreoffice-fresh: Office suite'
'thunderbird: Email client'
)
package() {
# Meta-package, no files
mkdir -p "$pkgdir/etc/skel/.config"
# Create default user configuration
cat > "$pkgdir/etc/skel/.xinitrc" << 'XINITRC'
#!/bin/sh
exec startxfce4
XINITRC
chmod +x "$pkgdir/etc/skel/.xinitrc"
}
EOF
cd /tmp
makepkg -si --noconfirm# Copy to repository
cp /tmp/xfce-desktop-complete-*.pkg.tar.zst /repo/custom/
# Update database
repo-add /repo/custom/custom.db.tar.gz \
/repo/custom/xfce-desktop-complete-*.pkg.tar.zst
# Sync
pacman -Sy- Install XFCE core packages
- Install and configure LightDM
- Start the display manager
- Login and explore the desktop
- Document the components installed
Expected Outcome: Working XFCE desktop with graphical login
- Install additional themes and icons
- Change desktop theme to Arc-Dark
- Configure panel plugins
- Set custom wallpaper
- Configure keyboard shortcuts
Expected Outcome: Customized XFCE desktop matching your preferences
- Create two test user accounts
- Configure different desktop settings for each
- Test switching between users
- Configure auto-login for one user
- Verify session isolation
Expected Outcome: Multi-user desktop environment working correctly
- Install Firefox and configure as default browser
- Install and configure email client
- Set up file associations
- Configure application menu
- Test launching applications from various methods
Expected Outcome: Integrated application environment
- Measure baseline resource usage
- Disable unnecessary services
- Optimize compositor settings
- Configure lightweight alternatives
- Document performance improvements
Expected Outcome: Optimized XFCE desktop with minimal resource usage
# Install screen locker
pacman -S --noconfirm xfce4-screensaver
# Configure automatic lock
xfconf-query -c xfce4-screensaver -p /lock/enabled -s true
xfconf-query -c xfce4-screensaver -p /saver/idle-activation/delay -s 10
# Lock on suspend
xfconf-query -c xfce4-power-manager \
-p /xfce4-power-manager/lock-screen-suspend-hibernate -s true# In LightDM configuration
cat >> /etc/lightdm/lightdm.conf << 'EOF'
[Seat:*]
allow-guest=false
EOF# Allow common desktop services
ufw allow mdns # Avahi/mDNS
ufw allow cups # Printing
# Block unnecessary ports
ufw deny 23 # Telnet
ufw deny 21 # FTP# Enable AppArmor profiles for desktop apps
aa-enforce /etc/apparmor.d/usr.bin.firefox
aa-enforce /etc/apparmor.d/usr.bin.thunderbirdWith the desktop environment installed and configured, you have a complete graphical Linux distribution. You can now:
- Install additional applications as needed
- Configure system-wide policies (Chapter 8 - Security Hardening)
- Set up container support for desktop applications (Chapter 9)
- Create an ISO image for distribution (Chapter 10)
- XFCE Documentation: https://docs.xfce.org/
- XFCE Wiki: https://wiki.xfce.org/
- LightDM Configuration: https://wiki.archlinux.org/title/LightDM
- GTK Theming: https://wiki.gnome.org/Projects/GnomeThemes
- NetworkManager: https://wiki.archlinux.org/title/NetworkManager
- PulseAudio: https://www.freedesktop.org/wiki/Software/PulseAudio/
- Desktop Entry Specification: https://specifications.freedesktop.org/desktop-entry-spec/