50 lines
1.2 KiB
Bash
50 lines
1.2 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
target_url="${1:-http://localhost:8081}"
|
|
|
|
find_browser() {
|
|
local candidate
|
|
for candidate in "$@"; do
|
|
if command -v "$candidate" >/dev/null 2>&1; then
|
|
printf '%s' "$candidate"
|
|
return 0
|
|
fi
|
|
done
|
|
return 1
|
|
}
|
|
|
|
browser=""
|
|
browser_kind=""
|
|
|
|
if browser="$(find_browser google-chrome-stable google-chrome chromium chromium-browser msedge microsoft-edge firefox)"; then
|
|
case "$browser" in
|
|
firefox)
|
|
browser_kind="firefox"
|
|
;;
|
|
msedge|microsoft-edge)
|
|
browser_kind="edge"
|
|
;;
|
|
*)
|
|
browser_kind="chrome"
|
|
;;
|
|
esac
|
|
else
|
|
echo "No supported browser was found."
|
|
echo "Tried Chrome, Chromium, Edge, and Firefox in PATH."
|
|
exit 1
|
|
fi
|
|
|
|
kiosk_profile="${XDG_DATA_HOME:-$HOME/.local/share}/pulse-signage/kiosk-browser-profile"
|
|
mkdir -p "$kiosk_profile"
|
|
|
|
echo "Launching ${browser_kind} in kiosk mode: ${target_url}"
|
|
|
|
case "$browser_kind" in
|
|
firefox)
|
|
exec "$browser" -no-remote -profile "$kiosk_profile" -new-window -kiosk "$target_url"
|
|
;;
|
|
edge|chrome)
|
|
exec "$browser" --disable-notifications --no-first-run --no-default-browser-check --new-window --kiosk --user-data-dir="$kiosk_profile" "$target_url"
|
|
;;
|
|
esac |