Refactor screen rotation setup and GTK theme configuration in first-boot process

Update the one-shot script to set screen rotation using kanshi based on kernel command line parameters, replacing the previous wlr-randr method. The script now writes the configuration to ~/.config/kanshi/config and sets the GTK dark theme (PiXnoir or Adwaita-dark) at first login. Additionally, enhance documentation to reflect these changes and clarify the role of the new script in the first-boot process.
This commit is contained in:
nearxos
2026-02-23 09:59:32 +02:00
parent fd4e54f125
commit 8b4930d4b9
13 changed files with 488 additions and 113 deletions

View File

@@ -134,8 +134,26 @@ step_02_packages() {
log "Packages installed successfully"
}
# --- Step 03: Kiosk files from file server ---
step_03_kiosk_files() {
# --- Step 03: reTerminal DM drivers (Seeed) ---
step_03_reterminal_drivers() {
if [[ -z "$RETERMINAL_REPO_URL" ]]; then
log "Skipping reTerminal drivers (RETERMINAL_REPO_URL not set)"
return 0
fi
REPO_DIR="/tmp/seeed-linux-dtoverlays"
log "Cloning seeed-linux-dtoverlays to $REPO_DIR ..."
git clone --depth 1 "$RETERMINAL_REPO_URL" "$REPO_DIR"
log "Running reTerminal.sh --device $RETERMINAL_DEVICE from $REPO_DIR ..."
if ( cd "$REPO_DIR" && "$REPO_DIR/scripts/reTerminal.sh" --device "$RETERMINAL_DEVICE" ); then
log "reTerminal DM drivers installed (reboot will apply)"
else
log "WARNING: reTerminal.sh failed (see log above). Display/touch may still work; you can retry later with: cd $REPO_DIR && sudo ./scripts/reTerminal.sh --device $RETERMINAL_DEVICE"
fi
rm -rf "$REPO_DIR"
}
# --- Step 04: Kiosk files from file server ---
step_04_kiosk_files() {
log "Creating $AUTOSTART"
mkdir -p "$AUTOSTART"
log "Downloading start-chromium.sh from ${FILE_SERVER}/start-chromium.sh"
@@ -147,8 +165,8 @@ step_03_kiosk_files() {
log "Kiosk files installed under $PI_HOME and $AUTOSTART"
}
# --- Step 04: Boot splash and wallpaper ---
step_04_splash_wallpaper() {
# --- Step 05: Boot splash and wallpaper ---
step_05_splash_wallpaper() {
log "Creating $PLYMOUTH_DIR and /usr/share/rpd-wallpaper"
mkdir -p "$PLYMOUTH_DIR" /usr/share/rpd-wallpaper
if curl -fsSL "${FILE_SERVER}/splash.png" -o "$PLYMOUTH_DIR/splash.png"; then
@@ -183,10 +201,32 @@ step_04_splash_wallpaper() {
else
log "WARNING: Could not download splash.png"
fi
# Optional: taskbar start button icon from file server (start-here.png)
if curl -fsSL "${FILE_SERVER}/start-here.png" -o /tmp/start-here.png; then
PIXTRIX_PLACES="/usr/share/icons/PiXtrix"
if [[ -d "$PIXTRIX_PLACES/32x32/places" ]]; then
for s in 16 24 32 48 64 96; do
DEST="$PIXTRIX_PLACES/${s}x${s}/places/start-here.png"
if [[ -d "$(dirname "$DEST")" ]]; then
rm -f "$DEST"
if command -v convert >/dev/null 2>&1; then
convert /tmp/start-here.png -resize "${s}x${s}" "$DEST" 2>/dev/null && true
else
cp /tmp/start-here.png "$DEST"
fi
chmod 644 "$DEST"
fi
done
log "Taskbar start button icon (start-here.png) installed from file server"
else
log "WARNING: PiXtrix theme places dir not found; skipped taskbar icon"
fi
rm -f /tmp/start-here.png
fi
}
# --- Step 05: LightDM session ---
step_05_lightdm() {
# --- Step 06: LightDM session ---
step_06_lightdm() {
mkdir -p /etc/lightdm/lightdm.conf.d
if curl -fsSL "${FILE_SERVER}/99-default-session.conf" -o /etc/lightdm/lightdm.conf.d/99-default-session.conf 2>/dev/null; then
log "99-default-session.conf installed"
@@ -198,16 +238,36 @@ step_05_lightdm() {
sed -i "s/^autologin-session=.*/autologin-session=$LIGHTDM_SESSION/" /etc/lightdm/lightdm.conf
log "Patched /etc/lightdm/lightdm.conf to use $LIGHTDM_SESSION"
fi
# Delay LightDM on first boot after provisioning so reTerminal DM DSI panel has time to init (avoids black screen on first reboot)
mkdir -p /etc/systemd/system/lightdm.service.d
cat > /etc/systemd/system/cm4-await-display.service << 'AWAITSVC'
[Unit]
Description=Wait for reTerminal DM display on first boot after provisioning
Before=lightdm.service
DefaultDependencies=no
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c 'if [ -f /var/lib/cm4-provisioning/await-display ]; then echo "Waiting 18s for DSI panel..."; sleep 18; rm -f /var/lib/cm4-provisioning/await-display; fi'
[Install]
WantedBy=graphical.target
AWAITSVC
printf '%s\n' '[Unit]' 'After=cm4-await-display.service' > /etc/systemd/system/lightdm.service.d/99-await-display.conf
systemctl daemon-reload
systemctl enable cm4-await-display.service 2>/dev/null || true
log "Installed cm4-await-display.service (delays LightDM on first reboot after provisioning)"
}
# --- Step 06: Maliit on-screen keyboard ---
step_06_maliit() {
# --- Step 07: Maliit on-screen keyboard ---
step_07_maliit() {
mkdir -p "$AUTOSTART" "$PI_HOME/.config"
curl -fsSL "${FILE_SERVER}/maliit-keyboard.desktop" -o "$AUTOSTART/maliit-keyboard.desktop" 2>/dev/null && log "maliit-keyboard.desktop installed" || log "WARNING: Could not download maliit-keyboard.desktop"
}
# --- Step 07: Dark theme (GTK) ---
step_07_dark_theme() {
# --- Step 08: Dark theme (GTK) ---
step_08_dark_theme() {
GTK_SETTINGS="$PI_HOME/.config/gtk-3.0/settings.ini"
mkdir -p "$(dirname "$GTK_SETTINGS")"
if [[ ! -f "$GTK_SETTINGS" ]]; then
@@ -220,24 +280,6 @@ step_07_dark_theme() {
chown -R "$PI_USER:$PI_USER" "$PI_HOME/.config"
}
# --- Step 08: reTerminal DM drivers (Seeed) ---
step_08_reterminal_drivers() {
if [[ -z "$RETERMINAL_REPO_URL" ]]; then
log "Skipping reTerminal drivers (RETERMINAL_REPO_URL not set)"
return 0
fi
REPO_DIR="/tmp/seeed-linux-dtoverlays"
log "Cloning seeed-linux-dtoverlays to $REPO_DIR ..."
git clone --depth 1 "$RETERMINAL_REPO_URL" "$REPO_DIR"
log "Running reTerminal.sh --device $RETERMINAL_DEVICE from $REPO_DIR ..."
if ( cd "$REPO_DIR" && "$REPO_DIR/scripts/reTerminal.sh" --device "$RETERMINAL_DEVICE" ); then
log "reTerminal DM drivers installed (reboot will apply)"
else
log "WARNING: reTerminal.sh failed (see log above). Display/touch may still work; you can retry later with: cd $REPO_DIR && sudo ./scripts/reTerminal.sh --device $RETERMINAL_DEVICE"
fi
rm -rf "$REPO_DIR"
}
# --- Step 09: Re-apply splash and Plymouth theme ---
step_09_reapply_splash() {
CFG_PATH="/boot/firmware/config.txt"
@@ -277,6 +319,17 @@ step_10_cmdline() {
step_11_oneshots() {
if [[ -n "$DSI_ROTATE" ]]; then
log "Rotation is set via kernel cmdline (video=DSI-1:rotate=$DSI_ROTATE)"
# Install set-rotation-at-login to write ~/.config/kanshi/config at every login (same as Control Center)
if curl -fsSL "${FILE_SERVER}/set-rotation-at-login.sh" -o "$PI_HOME/set-rotation-at-login.sh" 2>/dev/null; then
chmod 755 "$PI_HOME/set-rotation-at-login.sh"
chown "$PI_USER:$PI_USER" "$PI_HOME/set-rotation-at-login.sh"
if curl -fsSL "${FILE_SERVER}/set-rotation-at-login.desktop" -o /tmp/set-rotation-at-login.desktop 2>/dev/null; then
sed "s|/home/pi|$PI_HOME|g" /tmp/set-rotation-at-login.desktop > "$AUTOSTART/set-rotation-at-login.desktop"
chown "$PI_USER:$PI_USER" "$AUTOSTART/set-rotation-at-login.desktop"
log "Installed set-rotation-at-login (re-applies rotation from cmdline every login)"
fi
rm -f /tmp/set-rotation-at-login.desktop
fi
fi
if [[ -n "$ONESHOT_SCRIPTS" ]]; then
for _name in $ONESHOT_SCRIPTS; do
@@ -298,6 +351,9 @@ step_13_reboot() {
DEVICE_IP="$(hostname -I 2>/dev/null | awk '{print $1}')"
report_status "done" "First-boot complete" "13" "reboot" "$DEVICE_IP"
log "Device IP: ${DEVICE_IP:-unknown}"
# Flag for cm4-await-display.service: on next boot delay LightDM so DSI panel can init (avoids black screen)
mkdir -p /var/lib/cm4-provisioning
touch /var/lib/cm4-provisioning/await-display
log "=== first-boot.sh finished, rebooting ==="
reboot
}
@@ -305,12 +361,12 @@ step_13_reboot() {
# --- Main: run steps in order ---
run_step 01 hostname
run_step 02 packages
run_step 03 kiosk_files
run_step 04 splash_wallpaper
run_step 05 lightdm
run_step 06 maliit
run_step 07 dark_theme
run_step 08 reterminal_drivers
run_step 03 reterminal_drivers
run_step 04 kiosk_files
run_step 05 splash_wallpaper
run_step 06 lightdm
run_step 07 maliit
run_step 08 dark_theme
run_step 09 reapply_splash
run_step 10 cmdline
run_step 11 oneshots