Skip to content

Instantly share code, notes, and snippets.

@vchatela
Created January 12, 2026 19:15
Show Gist options
  • Select an option

  • Save vchatela/7e3d0d3ada69477e1750a4e2c5443370 to your computer and use it in GitHub Desktop.

Select an option

Save vchatela/7e3d0d3ada69477e1750a4e2c5443370 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Immich Frame Kiosk Mode Script
# Generated by Ansible for {{ inventory_hostname }}
# Configuration
WEBSITE_URL="{{ hostvars[inventory_hostname]['immich-kiosk-url'] }}"
# Detect which Chromium binary is available
if command -v chromium >/dev/null 2>&1; then
CHROMIUM_BIN="chromium"
elif command -v chromium-browser >/dev/null 2>&1; then
CHROMIUM_BIN="chromium-browser"
else
echo "Error: Neither chromium nor chromium-browser found"
exit 1
fi
echo "Using Chromium binary: $CHROMIUM_BIN"
# Disable screensaver, screen blanking, and power management
xset s off
xset s noblank
xset -dpms
# Auto-detect screen resolution
RESOLUTION=$(xrandr 2>/dev/null | grep '*' | awk '{print $1}')
if [ -z "$RESOLUTION" ]; then
RESOLUTION="1920x1080" # Default fallback can be ="1280x720"
fi
SCREEN_WIDTH=$(echo $RESOLUTION | cut -d 'x' -f1)
SCREEN_HEIGHT=$(echo $RESOLUTION | cut -d 'x' -f2)
echo "Detected screen resolution: ${SCREEN_WIDTH}x${SCREEN_HEIGHT}"
# Check internet connection using ping before launching Chromium
if ping -c 1 -W 2 google.com >/dev/null 2>&1; then
echo "Internet connected. Proceeding with Chromium launch."
else
echo "No internet connection detected. Exiting."
exit 1
fi
# Allow quitting the X server with CTRL-ALT-Backspace
# setxkbmap -option terminate:ctrl_alt_bksp
# Prevent Chromium restore prompts
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State' 2>/dev/null
sed -i 's/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences 2>/dev/null
# Clean up Chromium cache, cookies, and logs
find ~/.config/chromium/Default/ -type f \( -name "Cookies" -o -name "History" -o -name "*.log" -o -name "*.ldb" -o -name "*.sqlite" \) -delete 2>/dev/null
rm -rf ~/.config/chromium/Default/Logs/* 2>/dev/null
# Clear system logs
sudo journalctl --vacuum-time=1d
sudo find /var/log -type f \( -name "*.log" -o -name "*.gz" -o -name "*.1" \) -delete 2>/dev/null
sudo truncate -s 0 /var/log/syslog /var/log/dmesg 2>/dev/null
# Kill any existing Chromium instances
pkill -9 chromium 2>/dev/null
pkill -9 chromium-browser 2>/dev/null
pkill -9 chrome 2>/dev/null
# Start Chromium in kiosk mode
$CHROMIUM_BIN --kiosk --disable-gpu --noerrdialogs --disable-infobars --disable-features=TranslateUI \
--disable-session-crashed-bubble --no-sandbox --disable-notifications --disable-sync-preferences \
--no-sandbox --disable-background-mode --disable-popup-blocking --no-first-run \
--enable-gpu-rasterization --disable-translate --disable-logging --disable-default-apps \
--disable-extensions --disable-crash-reporter --disable-pdf-extension --disable-new-tab-first-run \
--disable-dev-shm-usage --start-maximized --mute-audio --disable-crashpad --hide-scrollbars \
--ash-hide-cursor --memory-pressure-off --force-device-scale-factor=1 --window-position=0,0 \
--disk-cache-size=1 --media-cache-size=1 --js-flags="--max-old-space-size=128" --no-memcheck\
--check-for-update-interval=31536000 --simulate-outdated-no-au='Tue, 31 Dec 2099 23:59:59 GMT' \
--window-size=${SCREEN_WIDTH},${SCREEN_HEIGHT} "$WEBSITE_URL" &
if [ $? -eq 0 ]; then
echo "Chromium started successfully."
else
echo "Failed to start Chromium."
sudo reboot
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment