Skip to content

Commit 83f280e

Browse files
steveseguinactions-user
authored andcommitted
feat(console): Add customizable splash screens, background, and input control
Enhances the local console display experience with dynamic visual feedback and operational control, making the Raspberry Ninja device feel more like a dedicated appliance. - **Installer (`installers/nvidia_jetson/setup_autostart.sh`):** - Adds a prompt to configure the initial splash background color for the playback TTY (supporting named colors or hex values). - Integrates `setterm` and ANSI escape sequences to apply the chosen background color and palette via `ExecStartPre` in the systemd service. - Introduces an option to hide the cursor and lock local keyboard input on the playback TTY, dedicating the console solely to video output. - Ensures keyboard input and cursor visibility are restored on service stop (`ExecStopPost`). - **Core Application (`publish.py`):** - Introduces `--splashscreen-idle` and `--splashscreen-connecting` command-line arguments to specify image paths for custom splash screens. - Implements a dynamic GStreamer display chain using `gst-video-mixer` and appropriate display sinks (e.g., `autovideosink`, `nvdrmvideosink`) to render either image splash screens or the active video stream. - Automatically switches between the "connecting" splash screen, "idle" splash screen, and live video stream based on WebRTC peer connection states when in viewer mode (`--view`). - Includes robust GStreamer element management and cleanup for the display chain. [auto-enhanced]
1 parent 91820b4 commit 83f280e

2 files changed

Lines changed: 718 additions & 230 deletions

File tree

installers/nvidia_jetson/setup_autostart.sh

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ fi
2121

2222
chvt_path="$(command -v chvt || true)"
2323
setterm_path="$(command -v setterm || true)"
24+
stty_path="$(command -v stty || true)"
2425

2526
if [[ -z "${chvt_path}" ]]; then
2627
echo "Could not locate 'chvt'. Aborting."
@@ -32,6 +33,15 @@ if [[ -z "${setterm_path}" ]]; then
3233
exit 1
3334
fi
3435

36+
if [[ -z "${stty_path}" ]]; then
37+
echo "Could not locate 'stty'. Aborting."
38+
exit 1
39+
fi
40+
41+
escape_for_single_quotes() {
42+
printf "%s" "$1" | sed "s/'/'\"'\"'/g"
43+
}
44+
3545
playback_tty="/dev/tty4"
3646
playback_tty_name="${playback_tty#/dev/}"
3747
playback_vt_number="${playback_tty_name#tty}"
@@ -64,6 +74,32 @@ if [[ -z "${start_command}" ]]; then
6474
exit 1
6575
fi
6676

77+
default_splash_color="black"
78+
read -rp "Splash background color (named or #RRGGBB) [${default_splash_color}]: " splash_color_input
79+
splash_color_input="${splash_color_input:-$default_splash_color}"
80+
splash_color_lower="$(echo "${splash_color_input}" | tr '[:upper:]' '[:lower:]')"
81+
82+
palette_hex=""
83+
splash_color_summary="${splash_color_input}"
84+
85+
if [[ "${splash_color_lower}" =~ ^#?[0-9a-f]{6}$ ]]; then
86+
splash_hex="${splash_color_lower#\#}"
87+
splash_hex="$(echo "${splash_hex}" | tr '[:lower:]' '[:upper:]')"
88+
palette_hex="${splash_hex}"
89+
setterm_background="black"
90+
splash_color_summary="#${splash_hex}"
91+
else
92+
case "${splash_color_lower}" in
93+
black|blue|cyan|green|magenta|red|white|yellow)
94+
setterm_background="${splash_color_lower}"
95+
;;
96+
*)
97+
echo "Unsupported splash color '${splash_color_input}'. Use one of: black, blue, cyan, green, magenta, red, white, yellow, or #RRGGBB." >&2
98+
exit 1
99+
;;
100+
esac
101+
fi
102+
67103
read -rp "Keep the desktop GUI running? [y/N]: " keep_gui
68104
keep_gui="$(echo "${keep_gui:-N}" | tr '[:upper:]' '[:lower:]')"
69105

@@ -206,6 +242,20 @@ else
206242
blanking_status="Pending"
207243
fi
208244

245+
read -rp "Hide cursor and lock keyboard input on ${playback_tty}? This makes the local console unresponsive until the service stops. [y/N]: " disable_local_input
246+
disable_local_input="$(echo "${disable_local_input:-N}" | tr '[:upper:]' '[:lower:]')"
247+
248+
setterm_cursor_flag=""
249+
input_lock_summary="disabled (local keyboard active)"
250+
restore_shell_commands=()
251+
252+
if [[ "${disable_local_input}" == "y" ]]; then
253+
setterm_cursor_flag="--cursor off"
254+
input_lock_summary="enabled (requires remote access)"
255+
restore_shell_commands+=("${stty_path} -F ${playback_tty} sane")
256+
restore_shell_commands+=("TERM=linux ${setterm_path} --term linux --cursor on >${playback_tty}")
257+
fi
258+
209259
service_name="raspberry-ninja"
210260
service_path="/etc/systemd/system/${service_name}.service"
211261

@@ -218,8 +268,23 @@ if [[ -f "${service_path}" ]]; then
218268
fi
219269
fi
220270

221-
escaped_cmd=$(printf "%s" "${start_command}" | sed "s/'/'\"'\"'/g")
271+
pre_shell_commands=()
272+
if [[ "${disable_local_input}" == "y" ]]; then
273+
pre_shell_commands+=("${stty_path} -F ${playback_tty} -echo -icanon")
274+
fi
275+
276+
setterm_args="--term linux --clear all --foreground ${setterm_background} --background ${setterm_background}"
277+
if [[ -n "${setterm_cursor_flag}" ]]; then
278+
setterm_args+=" ${setterm_cursor_flag}"
279+
fi
280+
281+
if [[ -n "${palette_hex}" ]]; then
282+
pre_shell_commands+=("printf '\\033]P0${palette_hex}\\033\\\\' >${playback_tty}")
283+
fi
222284

285+
pre_shell_commands+=("TERM=linux ${setterm_path} ${setterm_args} >${playback_tty}")
286+
287+
escaped_start_cmd="$(escape_for_single_quotes "${start_command}")"
223288
{
224289
echo "[Unit]"
225290
echo "Description=Raspberry Ninja Autostart (Jetson)"
@@ -242,8 +307,19 @@ escaped_cmd=$(printf "%s" "${start_command}" | sed "s/'/'\"'\"'/g")
242307
echo "StandardOutput=journal"
243308
echo "StandardError=journal"
244309
echo "ExecStartPre=${chvt_path} ${playback_vt_number}"
245-
echo "ExecStartPre=/bin/sh -c 'TERM=linux ${setterm_path} --term linux --clear all --foreground black --background black --cursor off >${playback_tty}'"
246-
echo "ExecStart=/bin/bash -lc '${escaped_cmd}'"
310+
if [[ "${#pre_shell_commands[@]}" -gt 0 ]]; then
311+
for cmd in "${pre_shell_commands[@]}"; do
312+
escaped_pre="$(escape_for_single_quotes "${cmd}")"
313+
echo "ExecStartPre=/bin/sh -c '${escaped_pre}'"
314+
done
315+
fi
316+
if [[ "${#restore_shell_commands[@]}" -gt 0 ]]; then
317+
for cmd in "${restore_shell_commands[@]}"; do
318+
escaped_restore="$(escape_for_single_quotes "${cmd}")"
319+
echo "ExecStopPost=/bin/sh -c '${escaped_restore}'"
320+
done
321+
fi
322+
echo "ExecStart=/bin/bash -lc '${escaped_start_cmd}'"
247323
echo
248324
echo "[Install]"
249325
echo "WantedBy=multi-user.target"
@@ -294,6 +370,8 @@ Configuration complete!
294370
- Systemd service : ${service_path}
295371
- Runs as user : ${service_user}
296372
- Launch command : ${start_command}
373+
- Splash color : ${splash_color_summary}
374+
- Input lock : ${input_lock_summary}
297375
- Playback console: ${playback_tty} (${playback_console_status})
298376
- Desktop status : ${gui_status}
299377
- Screen blanking : ${blanking_status}

0 commit comments

Comments
 (0)