Files
dropshell-templates/squashdisplay/configure.sh
Your Name 22ca6f07d4
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 34s
attempt to add squash stuff. Tailscale works!
2025-09-07 23:11:01 +12:00

132 lines
4.4 KiB
Bash
Executable File

#!/bin/bash
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "KIOSK_USER" "KIOSK_URL"
# Squash Display Configure Script - Update kiosk settings
echo "Squash Display Configuration Update"
echo "===================================="
echo ""
echo "This will update the kiosk configuration with current settings:"
echo " URL: ${KIOSK_URL}"
echo " Display: ${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}@${DISPLAY_REFRESH}Hz"
echo ""
# Update kiosk.sh script
if [ -f "/home/${KIOSK_USER}/kiosk.sh" ]; then
echo "Updating kiosk script..."
# Create updated script
cat <<'EOF' | sudo tee /home/${KIOSK_USER}/kiosk.sh.new > /dev/null
#!/bin/bash
# Disable screen blanking and power management
xset s noblank
xset s off
xset -dpms
# Hide cursor after 1 second of inactivity
unclutter -idle 1 &
# Force display resolution
xrandr --output HDMI-1 --mode DISPLAY_WIDTH_PLACEHOLDERxDISPLAY_HEIGHT_PLACEHOLDER --rate DISPLAY_REFRESH_PLACEHOLDER 2>/dev/null || \
xrandr --output HDMI-2 --mode DISPLAY_WIDTH_PLACEHOLDERxDISPLAY_HEIGHT_PLACEHOLDER --rate DISPLAY_REFRESH_PLACEHOLDER 2>/dev/null || \
xrandr --output default --mode DISPLAY_WIDTH_PLACEHOLDERxDISPLAY_HEIGHT_PLACEHOLDER --rate DISPLAY_REFRESH_PLACEHOLDER 2>/dev/null || true
# Start Chromium in kiosk mode
chromium-browser \
--window-size=DISPLAY_WIDTH_PLACEHOLDER,DISPLAY_HEIGHT_PLACEHOLDER \
--window-position=0,0 \
--noerrdialogs \
--disable-infobars \
--disable-features=TranslateUI \
--disable-extensions \
--disable-plugins \
--disable-web-security \
--disable-features=VizDisplayCompositor \
--start-fullscreen \
--kiosk \
--incognito \
--no-first-run \
--fast \
--fast-start \
--disable-default-apps \
--disable-translate \
--disable-background-timer-throttling \
--disable-renderer-backgrounding \
--disable-backgrounding-occluded-windows \
--disable-component-extensions-with-background-pages \
--autoplay-policy=no-user-gesture-required \
"KIOSK_URL_PLACEHOLDER"
EOF
# Replace placeholders with actual values
sudo sed -i "s|DISPLAY_WIDTH_PLACEHOLDER|${DISPLAY_WIDTH}|g" /home/${KIOSK_USER}/kiosk.sh.new
sudo sed -i "s|DISPLAY_HEIGHT_PLACEHOLDER|${DISPLAY_HEIGHT}|g" /home/${KIOSK_USER}/kiosk.sh.new
sudo sed -i "s|DISPLAY_REFRESH_PLACEHOLDER|${DISPLAY_REFRESH}|g" /home/${KIOSK_USER}/kiosk.sh.new
sudo sed -i "s|KIOSK_URL_PLACEHOLDER|${KIOSK_URL}|g" /home/${KIOSK_USER}/kiosk.sh.new
# Replace old script
sudo mv /home/${KIOSK_USER}/kiosk.sh.new /home/${KIOSK_USER}/kiosk.sh
sudo chmod +x /home/${KIOSK_USER}/kiosk.sh
sudo chown ${KIOSK_USER}:${KIOSK_USER} /home/${KIOSK_USER}/kiosk.sh
echo "✓ Kiosk script updated"
else
echo "✗ Kiosk script not found at /home/${KIOSK_USER}/kiosk.sh"
echo " Run installation first: ./install.sh"
exit 1
fi
# Update GPU memory if on Raspberry Pi
if [ -f "/boot/firmware/config.txt" ] || [ -f "/boot/config.txt" ]; then
echo "Updating GPU memory allocation..."
CONFIG_FILE="/boot/firmware/config.txt"
[ -f "/boot/config.txt" ] && CONFIG_FILE="/boot/config.txt"
if ! grep -q "^gpu_mem=" ${CONFIG_FILE}; then
echo "gpu_mem=${GPU_MEM}" | sudo tee -a ${CONFIG_FILE} > /dev/null
else
sudo sed -i "s/^gpu_mem=.*/gpu_mem=${GPU_MEM}/" ${CONFIG_FILE}
fi
echo "✓ GPU memory set to ${GPU_MEM}MB"
fi
# Restart kiosk if it's running
if pgrep -f "chromium.*--kiosk" >/dev/null 2>&1; then
echo ""
echo "Restarting kiosk with new configuration..."
# Kill existing Chromium process
pkill -f "chromium.*--kiosk"
# Give it a moment
sleep 2
# If watchdog is enabled, it will restart automatically
if [ "${ENABLE_WATCHDOG}" = "true" ]; then
echo "Watchdog will restart the kiosk automatically..."
else
# Manual restart
echo "Starting kiosk manually..."
sudo -u ${KIOSK_USER} DISPLAY=:0 /home/${KIOSK_USER}/kiosk.sh &
fi
echo "✓ Kiosk restarted with new configuration"
else
echo ""
echo "Kiosk is not currently running."
echo "Configuration will be applied on next start."
fi
echo ""
echo "Configuration update complete!"
echo ""
echo "Current settings:"
echo " URL: ${KIOSK_URL}"
echo " Display: ${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}@${DISPLAY_REFRESH}Hz"
echo " GPU Memory: ${GPU_MEM}MB"
echo ""
echo "To apply all changes, you may need to reboot: sudo reboot"