Skip to content

Commit adaf787

Browse files
authored
Merge pull request #3674 from joolswills/vlc_splashscreen
Switch to using VLC for splashscreen
2 parents d0200ec + f15fd70 commit adaf787

File tree

4 files changed

+68
-53
lines changed

4 files changed

+68
-53
lines changed

scriptmodules/supplementary/splashscreen.sh

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ rp_module_id="splashscreen"
1313
rp_module_desc="Configure Splashscreen"
1414
rp_module_section="main"
1515
rp_module_repo="git https://github.com/RetroPie/retropie-splashscreens.git master"
16-
rp_module_flags="noinstclean !all rpi !osmc !xbian !aarch64"
16+
rp_module_flags="noinstclean !all rpi !osmc !xbian"
1717

1818
function _update_hook_splashscreen() {
1919
# make sure splashscreen is always up to date if updating just RetroPie-Setup
@@ -32,9 +32,14 @@ function _video_exts_splashscreen() {
3232
}
3333

3434
function depends_splashscreen() {
35-
local params=(insserv)
36-
isPlatform "32bit" && params+=(omxplayer)
37-
getDepends "${params[@]}"
35+
# pin archive.raspberrypi.org version of VLC on buster as updated "security" vanilla version doesn't have mmal output
36+
if [[ "$__os_debian_ver" -lt 11 ]]; then
37+
cp "$md_data/rp-vlc" /etc/apt/preferences.d/
38+
# try and install vlc to force downgrade
39+
aptInstall --allow-downgrades vlc
40+
else
41+
getDepends vlc
42+
fi
3843
}
3944

4045
function install_bin_splashscreen() {
@@ -48,20 +53,28 @@ ConditionPathExists=$md_inst/asplashscreen.sh
4853
4954
[Service]
5055
Type=oneshot
56+
User=$__user
5157
ExecStart=$md_inst/asplashscreen.sh
5258
RemainAfterExit=yes
5359
5460
[Install]
5561
WantedBy=sysinit.target
5662
_EOF_
5763

58-
rp_installModule "omxiv" "_autoupdate_"
59-
6064
gitPullOrClone "$md_inst"
6165

6266
cp "$md_data/asplashscreen.sh" "$md_inst"
6367

6468
iniConfig "=" '"' "$md_inst/asplashscreen.sh"
69+
70+
if isPlatform "videocore"; then
71+
# set vlc mmal layer for videocore
72+
iniSet "CMD_OPTS" " --mmal-layer 10001"
73+
else
74+
# install script to kill splashscreen before running autostart scripts when using kms
75+
cp "$md_data/05-splash.sh" /etc/profile.d/
76+
fi
77+
6578
iniSet "ROOTDIR" "$rootdir"
6679
iniSet "DATADIR" "$datadir"
6780
iniSet "REGEX_IMAGE" "$(_image_exts_splashscreen)"
@@ -107,9 +120,6 @@ function disable_splashscreen() {
107120
function configure_splashscreen() {
108121
[[ "$md_mode" == "remove" ]] && return
109122

110-
# remove legacy service
111-
[[ -f "/etc/init.d/asplashscreen" ]] && insserv -r asplashscreen && rm -f /etc/init.d/asplashscreen
112-
113123
disable_plymouth_splashscreen
114124
enable_splashscreen
115125
[[ ! -f /etc/splashscreen.list ]] && default_splashscreen
@@ -118,8 +128,9 @@ function configure_splashscreen() {
118128
function remove_splashscreen() {
119129
enable_plymouth_splashscreen
120130
disable_splashscreen
121-
rp_callModule "omxiv" remove
122131
rm -f /etc/splashscreen.list /etc/systemd/system/asplashscreen.service
132+
rm -f /etc/apt/preferences.d/rp-vlc
133+
rm -f /etc/profile.d/05-splash.sh
123134
systemctl daemon-reload
124135
}
125136

@@ -229,7 +240,7 @@ function preview_splashscreen() {
229240

230241
local path
231242
local file
232-
local omxiv="/opt/retropie/supplementary/omxiv/omxiv"
243+
local splash_cmd="sudo -u $__user XDG_RUNTIME_DIR=/run/user/$SUDO_UID vlc --intf dummy --quiet --play-and-exit --image-duration 6"
233244
while true; do
234245
local cmd=(dialog --backtitle "$__backtitle" --menu "Choose an option." 22 86 16)
235246
local choice=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
@@ -241,13 +252,13 @@ function preview_splashscreen() {
241252
1)
242253
file=$(choose_splashscreen "$path" "image")
243254
[[ -z "$file" ]] && break
244-
$omxiv -b "$file"
255+
$splash_cmd "$file"
245256
;;
246257
2)
247258
file=$(mktemp)
248259
find "$path" -type f ! -regex ".*/\..*" ! -regex ".*LICENSE" ! -regex ".*README.*" ! -regex ".*\.sh" | sort > "$file"
249260
if [[ -s "$file" ]]; then
250-
$omxiv -t 6 -T blend -b --once -f "$file"
261+
tr "\n" "\0" <"$file" | xargs -0 $splash_cmd
251262
else
252263
printMsgs "dialog" "There are no splashscreens installed in $path"
253264
fi
@@ -257,7 +268,7 @@ function preview_splashscreen() {
257268
3)
258269
file=$(choose_splashscreen "$path" "video")
259270
[[ -z "$file" ]] && break
260-
omxplayer --no-osd -b --layer 10000 "$file"
271+
$splash_cmd "$file"
261272
;;
262273
esac
263274
done
@@ -270,10 +281,6 @@ function download_extra_splashscreen() {
270281
}
271282

272283
function gui_splashscreen() {
273-
if [[ ! -d "$md_inst" ]]; then
274-
rp_callModule splashscreen depends
275-
rp_callModule splashscreen install
276-
fi
277284
local cmd=(dialog --backtitle "$__backtitle" --menu "Choose an option." 22 86 16)
278285
while true; do
279286
local enabled=0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PID_FILE=/dev/shm/rp-splashscreen.pid
2+
if [ "`tty`" = "/dev/tty1" ] && [ -z "$DISPLAY" ] && [ -f "$PID_FILE" ]; then
3+
PID=`cat $PID_FILE`
4+
if ps -p $PID >/dev/null; then
5+
kill $PID >/dev/null 2>&1
6+
fi
7+
rm $PID_FILE
8+
fi

scriptmodules/supplementary/splashscreen/asplashscreen.sh

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,18 @@ ROOTDIR=""
44
DATADIR=""
55
REGEX_VIDEO=""
66
REGEX_IMAGE=""
7+
CMD="vlc --intf dummy --quiet --no-video-title-show --play-and-exit"
8+
CMD_OPTS=""
79

810
# Load user settings
911
. /opt/retropie/configs/all/splashscreen.cfg
1012

11-
is_fkms() {
12-
if grep -q okay /proc/device-tree/soc/v3d@7ec00000/status 2> /dev/null || grep -q okay /proc/device-tree/soc/firmwarekms@7e600000/status 2> /dev/null ; then
13-
return 0
14-
else
15-
return 1
16-
fi
17-
}
18-
1913
do_start () {
2014
local config="/etc/splashscreen.list"
2115
local line
2216
local re="$REGEX_VIDEO\|$REGEX_IMAGE"
23-
local omxiv="/opt/retropie/supplementary/omxiv/omxiv"
17+
local cmd="$CMD $CMD_OPTS"
2418
case "$RANDOMIZE" in
25-
disabled)
26-
line="$(head -1 "$config")"
27-
;;
2819
retropie)
2920
line="$(find "$ROOTDIR/supplementary/splashscreen" -type f | grep "$re" | shuf -n1)"
3021
;;
@@ -38,36 +29,38 @@ do_start () {
3829
line="$(cat "$config" | shuf -n1)"
3930
;;
4031
esac
41-
if $(echo "$line" | grep -q "$REGEX_VIDEO"); then
42-
# wait for dbus
43-
while ! pgrep "dbus" >/dev/null; do
44-
sleep 1
45-
done
46-
omxplayer --no-osd -o both -b --layer 10001 "$line"
47-
elif $(echo "$line" | grep -q "$REGEX_IMAGE"); then
48-
if [ "$RANDOMIZE" = "disabled" ]; then
49-
local count=$(wc -l <"$config")
50-
else
51-
local count=1
52-
fi
53-
[ $count -eq 0 ] && count=1
54-
[ $count -gt 12 ] && count=12
5532

56-
# Default duration is 12 seconds, check if configured otherwise
57-
[ -z "$DURATION" ] && DURATION=12
58-
local delay=$((DURATION/count))
59-
if [ "$RANDOMIZE" = "disabled" ]; then
60-
"$omxiv" --once -t $delay -b --layer 10001 -f "$config" >/dev/null 2>&1
61-
else
62-
"$omxiv" --once -t $delay -b --layer 10001 -r "$line" >/dev/null 2>&1
63-
fi
33+
if [ "$RANDOMIZE" = "disabled" ]; then
34+
local count=$(wc -l <"$config")
35+
else
36+
local count=1
37+
fi
38+
39+
[ $count -eq 0 ] && count=1
40+
[ $count -gt 12 ] && count=12
41+
42+
# Default duration is 12 seconds, check if configured otherwise
43+
[ -z "$DURATION" ] && DURATION=12
44+
local delay=$((DURATION/count))
45+
46+
cmd="$cmd --image-duration $delay"
47+
local pid
48+
if [ "$RANDOMIZE" = "disabled" ]; then
49+
tr "\n" "\0" <"$config" | xargs -0 $cmd & 2>/dev/null
50+
# get cmd pid (child of xargs)
51+
pid=`pgrep -P $!`
52+
else
53+
$cmd "$line" & 2>/dev/null
54+
pid=$!
6455
fi
56+
echo "$pid" >/dev/shm/rp-splashscreen.pid
57+
6558
exit 0
6659
}
6760

6861
case "$1" in
6962
start|"")
70-
do_start &
63+
do_start
7164
;;
7265
restart|reload|force-reload)
7366
echo "Error: argument '$1' not supported" >&2
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Package: vlc*
2+
Pin: origin archive.raspberrypi.org
3+
Pin-Priority: 1001
4+
5+
Package: libvlc*
6+
Pin: origin archive.raspberrypi.org
7+
Pin-Priority: 1001

0 commit comments

Comments
 (0)