Date Created: 2025-01-01
By: 16BitMiker
[ BACK.. ]
If you're spinning up Debian 12 virtual machines frequently and want a lightweight, ready-to-go desktop with auto-login, this script has you covered. It automates the installation of the LXQt desktop environment, configures the SDDM display manager, and enables automatic login β all in one go. Let's walk through how it works and why this setup can be a great choice for development, testing, or kiosk-style deployments.
ποΈ LXQt is a lightweight, Qt-based desktop environment thatβs ideal for virtual machines or low-resource systems. Itβs fast, customizable, and doesn't get in your way.
π Auto-login is useful for:
VM environments where the same user is always active
Developer testbeds
Kiosks or appliances
Streamlining the boot-to-desktop experience
This script is designed to be non-interactive and idempotent β making it safe to run in provisioning tools like Vagrant or cloud-init.
βx
# Enable safe shell scripting practices:
# -e: Exit on error
# -u: Treat unset variables as errors
# -x: Print commands before executing
# -o pipefail: Return the status of the last failed command in a pipeline
set -euxo pipefail
# Export environment variable so Perl doesn't prompt during installation
export PERL_MM_USE_DEFAULT=1
# Ensure Perl is installed silently
DEBIAN_FRONTEND=noninteractive PERL_MM_USE_DEFAULT=1 sudo apt-get -y \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" install perl
# Perl wrapper script for colored output and execution control:
perl -MTerm::ANSIColor=':constants' -nlE '
# Skip blank lines and comments
next if m~^$|^\#~;
# Print the command in green
say q|> |, GREEN $_, RESET "";
# Execute the command
system $_;
# If the system call fails, print the error in red
if ($? != 0)
{
warn q|> |, RED qq|Failure Detected: |, RESET qq|$!\n|;
}
# At the end of the script, print a success message
END
{
say q|> |, GREEN q|All Done! Bye bye :)|, RESET "";
}
' <<EOF
# Update package list and upgrade all packages
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
# Install LXQt desktop and required tools
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install \
task-lxqt-desktop sddm software-properties-common apt-transport-https \
ca-certificates curl gnupg2
# Install extra LXQt utilities and core apps
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install \
lxqt-themes lxqt-config pavucontrol-qt firefox-esr mousepad
# Create SDDM configuration directory
sudo mkdir -p /etc/sddm.conf.d
# Write autologin configuration:
# Session: lxqt.desktop
# User: current user (resolved via whoami)
sudo bash -c 'echo "[Autologin]" > /etc/sddm.conf.d/autologin.conf'
sudo bash -c 'echo "User=$(whoami)" >> /etc/sddm.conf.d/autologin.conf'
sudo bash -c 'echo "Session=lxqt.desktop" >> /etc/sddm.conf.d/autologin.conf'
sudo chmod 600 /etc/sddm.conf.d/autologin.conf
# Set SDDM as the default display manager
sudo bash -c 'echo "/usr/bin/sddm" > /etc/X11/default-display-manager && \
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure sddm'
# Clean up unused packages and apt cache
sudo DEBIAN_FRONTEND=noninteractive apt-get -y autoremove
sudo DEBIAN_FRONTEND=noninteractive apt-get clean
EOF
The embedded Perl block is more than aesthetic:
π’ It colorizes commands being executed (GREEN
)
π΄ Flags errors clearly if a command fails (RED
)
π Skips comments and empty lines to keep logs clean
π Ends with a friendly status message
This makes the script ideal for CI logs or remote provisioning where quick visual parsing is helpful.
The script creates a dedicated config snippet at /etc/sddm.conf.d/autologin.conf
with:
xxxxxxxxxx
[Autologin]
User=yourusername
Session=lxqt.desktop
This approach respects Debianβs modular SDDM config structure and avoids editing system-wide monolithic files. Using chmod 600
ensures only root can view or modify the file β a solid security practice.
Instead of prompting the user during install (which can break automation), the script directly sets SDDM as the default display manager and reconfigures it with:
xxxxxxxxxx
echo "/usr/bin/sddm" > /etc/X11/default-display-manager
dpkg-reconfigure sddm
This guarantees LXQt boots into the correct session automatically, even if other display managers are installed.
Save the script as debian-lxqt-setup.sh
Make it executable:
xxxxxxxxxx
chmod +x debian-lxqt-setup.sh
Run it:
xxxxxxxxxx
sudo ./debian-lxqt-setup.sh
β³ Depending on your network and VM specs, installation will take a few minutes.
This script is ideal for:
Developers spinning up disposable VMs
Retrocomputing fans using LXQt for lightweight DEs
System integrators building kiosk or appliance images
CI/CD pipelines that require a GUI base layer
This script provides a clean, reliable way to bootstrap a Debian 12 LXQt system with auto-login. Itβs designed for automation, but still human-friendly β with color-coded logs and clear failure handling. Whether you're building a dev environment or a minimal GUI server, it saves time and ensures consistency.
Happy hacking! ποΈ