Skip to content

Commit

Permalink
Fix EmulationStation resolution on exit | Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomsantos committed Jan 5, 2017
1 parent 2f7bfec commit 38f4856
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tools/Linux/kodi.sh.in
Expand Up @@ -28,7 +28,10 @@ LIBDIR="@libdir@"
CRASHLOG_DIR=${CRASHLOG_DIR:-$HOME}
USERDATA_DIR="${HOME}/.${bin_name}"

ORIGINAL_DEPTH=`fbset | head -3 | tail -1 | cut -d " " -f 10`
# 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
Expand All @@ -38,6 +41,28 @@ then
sudo service cec stop >/dev/null 2>&1
fi

# 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
}

save_screen_mode

# Workaround for high CPU load with nvidia GFX
export __GL_YIELD=USLEEP
Expand Down Expand Up @@ -181,6 +206,8 @@ do
fi
done

# Raspberry Pi fixes
restore_screen_mode
if [ -f "/usr/bin/cec-daemon" ]
then
sudo service cec start >/dev/null 2>&1
Expand Down

0 comments on commit 38f4856

Please sign in to comment.