Add Full HD display configuration to startup script
- Added configure_display_resolution() function to force 1920x1080 output - Supports three methods: xrandr (X11), tvservice (RPi native), /boot/config.txt (persistent) - Ensures player displays Full HD on screens larger than 1920x1080 - Configuration runs automatically on each startup
This commit is contained in:
@@ -99,6 +99,80 @@ load_user_environment() {
|
|||||||
# Load the user environment early
|
# Load the user environment early
|
||||||
load_user_environment
|
load_user_environment
|
||||||
|
|
||||||
|
# Function to configure display output to Full HD (1920x1080)
|
||||||
|
configure_display_resolution() {
|
||||||
|
log_message "🖥️ Configuring display output to Full HD (1920x1080)..."
|
||||||
|
|
||||||
|
# Method 1: Try xrandr (works on X11 systems)
|
||||||
|
if command -v xrandr &>/dev/null && [ -n "$DISPLAY" ]; then
|
||||||
|
log_message "Attempting to set resolution via xrandr..."
|
||||||
|
|
||||||
|
# Get the primary display
|
||||||
|
primary_display=$(xrandr --query 2>/dev/null | grep " connected" | grep "primary\|preferred" | head -n 1 | awk '{print $1}')
|
||||||
|
|
||||||
|
if [ -z "$primary_display" ]; then
|
||||||
|
primary_display=$(xrandr --query 2>/dev/null | grep " connected" | head -n 1 | awk '{print $1}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$primary_display" ]; then
|
||||||
|
# Set output to 1920x1080 @ 60Hz
|
||||||
|
xrandr --output "$primary_display" --mode 1920x1080 --rate 60 2>/dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
log_message "✓ Display resolution set to 1920x1080 via xrandr"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Method 2: Try tvservice (native Raspberry Pi tool)
|
||||||
|
if command -v tvservice &>/dev/null; then
|
||||||
|
log_message "Attempting to set resolution via tvservice (RPi native)..."
|
||||||
|
|
||||||
|
# Get current HDMI status
|
||||||
|
hdmi_mode=$(tvservice -s 2>/dev/null | grep -oP 'DMT mode \K\d+')
|
||||||
|
|
||||||
|
# Set to HDMI mode 16 (1920x1080 @ 60Hz) - standard Full HD
|
||||||
|
tvservice -e "DMT 16" 2>/dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
log_message "✓ Display resolution set to 1920x1080 via tvservice (DMT mode 16)"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Method 3: Configure via /boot/config.txt (persistent RPi config)
|
||||||
|
if [ -f "/boot/config.txt" ] && command -v sudo &>/dev/null; then
|
||||||
|
log_message "Checking /boot/config.txt for display settings..."
|
||||||
|
|
||||||
|
# These settings ensure Full HD output on large displays
|
||||||
|
if ! grep -q "hdmi_group=2" /boot/config.txt; then
|
||||||
|
log_message "Adding HDMI display configuration to /boot/config.txt..."
|
||||||
|
# Backup config first
|
||||||
|
sudo cp /boot/config.txt /boot/config.txt.backup.$(date +%s)
|
||||||
|
|
||||||
|
# Add Full HD configuration
|
||||||
|
echo "" | sudo tee -a /boot/config.txt > /dev/null
|
||||||
|
echo "# Kiwy Signage Player - Full HD Display Configuration" | sudo tee -a /boot/config.txt > /dev/null
|
||||||
|
echo "hdmi_group=2" | sudo tee -a /boot/config.txt > /dev/null # DMT (monitor timings)
|
||||||
|
echo "hdmi_mode=16" | sudo tee -a /boot/config.txt > /dev/null # 1920x1080 @ 60Hz
|
||||||
|
echo "hdmi_drive=2" | sudo tee -a /boot/config.txt > /dev/null # Normal HDMI mode
|
||||||
|
echo "disable_overscan=1" | sudo tee -a /boot/config.txt > /dev/null # Disable overscan
|
||||||
|
echo "framebuffer_width=1920" | sudo tee -a /boot/config.txt > /dev/null
|
||||||
|
echo "framebuffer_height=1080" | sudo tee -a /boot/config.txt > /dev/null
|
||||||
|
|
||||||
|
log_message "✓ HDMI configuration added to /boot/config.txt"
|
||||||
|
log_message "⚠️ Display settings require reboot to take effect"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
log_message "✓ /boot/config.txt already configured for Full HD"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_message "Display configuration completed (1920x1080 Full HD target)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configure display before starting player
|
||||||
|
configure_display_resolution
|
||||||
|
|
||||||
# Function to check if player is healthy
|
# Function to check if player is healthy
|
||||||
check_health() {
|
check_health() {
|
||||||
# Check if heartbeat file exists and is recent (within last 60 seconds)
|
# Check if heartbeat file exists and is recent (within last 60 seconds)
|
||||||
|
|||||||
Reference in New Issue
Block a user