Skip to content

Commit

Permalink
kodi.sh.in: Strip down and simplify
Browse files Browse the repository at this point in the history
Matrix doesn't support legacy (no /dev/dri so no gbm) so strip that out.
unset DISPLAY and kodi gbm explicity rejects that
I belive openvt is cleaner that doing chvt twice
  • Loading branch information
popcornmix committed Dec 16, 2021
1 parent ff716cb commit f700659
Showing 1 changed file with 3 additions and 82 deletions.
85 changes: 3 additions & 82 deletions tools/Linux/kodi.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,62 +30,11 @@ CRASHLOG_DIR=${CRASHLOG_DIR:-$HOME}
KODI_DATA=${KODI_DATA:-"${HOME}/.${bin_name}"} # mapped to special://home/
WINDOWING=${WINDOWING:-"auto"}

# Black Screen on exit fix
ORIGINAL_DEPTH=`fbset | head -3 | tail -1 | cut -d " " -f 10`

# PiPplware fixes
if pgrep "fbi" > /dev/null
then
sudo killall fbi >/dev/null 2>&1
fi
if pgrep "cec-client" > /dev/null
then
if pgrep "cec-client" > /dev/null; then
sudo service cec stop >/dev/null 2>&1
fi

is_legacy() {
! grep -q okay /proc/device-tree/soc/v3d@7ec00000/status 2> /dev/null && ! grep -q okay /proc/device-tree/v3dbus/v3d@7ec04000/status 2> /dev/null
}

is_fkms() {
! is_legacy && grep -q okay /proc/device-tree/soc/firmwarekms@7e600000/status 2> /dev/null
}

is_kms() {
! is_legacy && ! grep -q okay /proc/device-tree/soc/firmwarekms@7e600000/status 2> /dev/null
}

# EmulationStation screen resolution fix
save_screen_mode() {
local status="$(tvservice -s)"
if echo "$status" | grep -qE "(PAL|NTSC)"; then
MODE_TYPE=$(echo "$status" | grep -oE "(PAL|NTSC)")
MODE_INFO=$(echo "$status" | grep -oE "([0-9]+\:[0-9]+)")
else
MODE_TYPE=$(echo "$status" | grep -oE "(CEA|DMT)")
MODE_INFO=$(echo "$status" | grep -oE "\([0-9]+\)" | tr -d '()')
fi
}

restore_screen_mode() {
if [ "$MODE_TYPE" = "PAL" ] || [ "$MODE_TYPE" = "NTSC" ]; then
tvservice -c "$MODE_TYPE $MODE_INFO" >/dev/null
else
tvservice -e "$MODE_TYPE $MODE_INFO" >/dev/null
fi
sleep 1
}

if is_legacy ; then
save_screen_mode
else
# if not legacy and running X11 change VT
if pgrep "X" > /dev/null; then
vt=$(sudo /bin/fgconsole)
sudo /bin/chvt 8
fi
fi

# Workaround for high CPU load with nvidia GFX
export __GL_YIELD=USLEEP

Expand Down Expand Up @@ -141,18 +90,6 @@ fi

APPORT_CORE="/var/crash/$(echo -n ${KODI_BINARY}${postfix}|tr / _).$(id -u).crash"

migrate_home()
{
[ "$(basename $0)" = "xbmc" ] && echo "WARNING: Running ${bin_name} as "xbmc" is deprecated and will be removed in later versions, please switch to using the ${bin_name} binary"

#check if data migration is needed
if [ -d "${HOME}/.xbmc" ] && [ ! -d "${KODI_DATA}" ]; then
echo "INFO: migrating userdata folder. Renaming ${HOME}/.xbmc to $KODI_DATA"
mv ${HOME}/.xbmc $KODI_DATA
touch ${KODI_DATA}/.kodi_data_was_migrated
fi
}

command_exists()
{
command -pv $1 >/dev/null 2>&1
Expand Down Expand Up @@ -252,7 +189,6 @@ print_crash_report()
echo "Crash report available at $FILE"
}

migrate_home
propagate_sigterm() {
kill -TERM "$CHILD" 2>/dev/null
}
Expand All @@ -272,7 +208,7 @@ while [ $(( $LOOP )) = "1" ]
do
[ -f "${APPORT_CORE}" ] && rm -f "${APPORT_CORE}"
LOOP=0
${KODI_BINARY}${postfix} $SAVED_ARGS &
unset DISPLAY; sudo openvt -sw -- su -c "${KODI_BINARY}${postfix} $SAVED_ARGS" $USER &
CHILD=$!
wait "${CHILD}"
RET=$?
Expand All @@ -286,22 +222,7 @@ do
done

# Raspberry Pi fixes
if is_legacy ; then
restore_screen_mode
fbset -depth 8 > /dev/null 2>&1
fbset -depth $ORIGINAL_DEPTH > /dev/null 2>&1
if pgrep "X" > /dev/null
then
xrefresh >/dev/null 2>&1
fi
else
# if not legacy and running X11 change VT
if pgrep "X" > /dev/null; then
sudo /bin/chvt $vt
fi
fi
if [ -f "/usr/bin/cec-daemon" ]
then
if [ -f "/usr/bin/cec-daemon" ]; then
sudo service cec start >/dev/null 2>&1
fi

Expand Down

0 comments on commit f700659

Please sign in to comment.