98 lines
2.8 KiB
Bash
98 lines
2.8 KiB
Bash
#!/bin/bash
|
|
# Home Assistant Dashboard Launcher
|
|
# Configure the URL below to point to your Home Assistant instance
|
|
|
|
# Log file for debugging
|
|
LOG_FILE="/tmp/homeassistant-dashboard.log"
|
|
exec > >(tee -a "$LOG_FILE") 2>&1
|
|
|
|
echo "$(date): Starting Home Assistant Dashboard launcher"
|
|
|
|
# Home Assistant URL
|
|
# Note: For auto-login, configure trusted networks in Home Assistant
|
|
# This computer's IP: 192.168.68.193
|
|
HA_URL="${HA_URL:-http://homeassistant.local:8123/dashboard-kiosk/0}"
|
|
|
|
echo "$(date): Dashboard URL: $HA_URL"
|
|
|
|
# Wait for network and display to be ready
|
|
echo "$(date): Waiting for network and display..."
|
|
sleep 5
|
|
|
|
# Wait for network connectivity
|
|
for i in {1..30}; do
|
|
if ping -c 1 -W 2 homeassistant.local > /dev/null 2>&1; then
|
|
echo "$(date): Network is ready"
|
|
break
|
|
fi
|
|
echo "$(date): Waiting for network... ($i/30)"
|
|
sleep 1
|
|
done
|
|
|
|
# Hide cursor after 3 seconds of inactivity
|
|
unclutter -idle 3 -root &
|
|
|
|
# Set display environment (Wayland)
|
|
export XDG_RUNTIME_DIR=/run/user/1000
|
|
# Auto-detect Wayland display
|
|
if [ -z "$WAYLAND_DISPLAY" ]; then
|
|
if [ -S "$XDG_RUNTIME_DIR/wayland-0" ]; then
|
|
export WAYLAND_DISPLAY=wayland-0
|
|
elif [ -S "$XDG_RUNTIME_DIR/wayland-1" ]; then
|
|
export WAYLAND_DISPLAY=wayland-1
|
|
fi
|
|
fi
|
|
|
|
# Wait for Wayland display to be ready
|
|
for i in {1..30}; do
|
|
if [ -S "$XDG_RUNTIME_DIR/wayland-0" ] || [ -S "$XDG_RUNTIME_DIR/wayland-1" ]; then
|
|
echo "$(date): Wayland display is ready"
|
|
break
|
|
fi
|
|
echo "$(date): Waiting for Wayland display... ($i/30)"
|
|
sleep 1
|
|
done
|
|
|
|
# Launch Firefox in kiosk mode
|
|
# --kiosk: Fullscreen mode
|
|
# --no-remote: Don't connect to existing Firefox instance
|
|
# --new-instance: Create new instance
|
|
# --disable-infobars: Hide info bars
|
|
# --disable-session-restore: Don't restore previous session
|
|
# MOZ_ENABLE_WAYLAND=1: Enable Wayland support
|
|
echo "$(date): Launching Firefox..."
|
|
MOZ_ENABLE_WAYLAND=1 firefox --kiosk \
|
|
--no-remote \
|
|
--new-instance \
|
|
--disable-infobars \
|
|
--disable-session-restore \
|
|
"$HA_URL" &
|
|
|
|
FIREFOX_PID=$!
|
|
echo "$(date): Firefox launched with PID: $FIREFOX_PID"
|
|
|
|
# Wait for Firefox to load, then inject auto-scroll script
|
|
sleep 8
|
|
echo "$(date): Attempting to inject auto-scroll script..."
|
|
|
|
# Try to inject JavaScript via Firefox remote debugging (if available)
|
|
# Or we'll need to use a different method
|
|
# For now, the user can inject manually or we use a bookmarklet approach
|
|
|
|
FIREFOX_PID=$!
|
|
echo "$(date): Firefox launched with PID: $FIREFOX_PID"
|
|
|
|
# Wait a moment then verify it's running
|
|
sleep 3
|
|
|
|
if ps -p $FIREFOX_PID > /dev/null 2>&1; then
|
|
echo "$(date): Firefox is running successfully"
|
|
else
|
|
echo "$(date): ERROR: Firefox process died!"
|
|
exit 1
|
|
fi
|
|
|
|
# Keep script running
|
|
wait $FIREFOX_PID
|
|
echo "$(date): Firefox exited"
|