Files
reterminal-dm4/chromium-setup/emmc-provisioning/cloud-init/set-rotation-once.sh

30 lines
1.0 KiB
Bash

#!/bin/bash
# One-shot: set reTerminal DM (labwc/Wayland) rotation to Right via wlr-randr, then remove self.
# Runs as user pi at first login. Logs to /var/log/first-boot.log.
FIRST_BOOT_LOG="/var/log/first-boot.log"
log() { echo "[$(date -Iseconds)] [set-rotation-once] $*" >> "$FIRST_BOOT_LOG" 2>/dev/null || true; }
log "started (labwc/wlr-randr)"
log "waiting 5s for compositor ..."
sleep 5
OUTPUT=""
if command -v wlr-randr &>/dev/null; then
OUTPUT=$(wlr-randr 2>/dev/null | awk '/^[A-Za-z0-9_-]+ /{print $1; exit}')
fi
if [[ -z "$OUTPUT" ]]; then
OUTPUT="DSI-1"
log "using default output: $OUTPUT"
fi
if [[ -n "$OUTPUT" ]] && command -v wlr-randr &>/dev/null; then
log "applying rotation right (transform 90) on $OUTPUT"
wlr-randr --output "$OUTPUT" --transform 90 2>&1 | while read -r line; do log "$line"; done
else
log "WARNING: wlr-randr not found or no output"
fi
log "removing one-shot desktop and script"
rm -f /home/pi/.config/autostart/set-rotation-once.desktop /home/pi/set-rotation-once.sh
log "finished"