Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Raspbian: Avoid black screen on kodi exit
#!/bin/bash
LOG_FILE=$HOME/.kodi/temp/kodi.log
rm $LOG_FILE 2> /dev/null
/usr/lib/kodi/kodi.bin --standalone &
while [[ ! -f $LOG_FILE ]] ; do
sleep 1s
done
while read line ; do
if [[ ${line} =~ "application stopped" ]] ; then
echo "Killing kodi"
break
fi
done < <(tail --pid=$$ -f -n0 $LOG_FILE)
killall kodi.bin
fbset -depth 8 && fbset -depth 16

Hello there,

Thanks for your kodi fix and whilst I appreciate the effort taken to fix the blank screen issue, when I click on exit in kodi, the desktop is not back in full and it looks like there is a memory issue and i have to click on various parts of the screen to get the full desktop back.

Please can you suggest me if I have to adjust any other settings for this fix ?

I had same problem, tried xrandr settings, arandr tried using xdotool to switch desktops - no avail
then found xrefresh sorts it.
Note: I found when testing parts of the original script above from a terminal that I had to wait a few seconds and set the LOG_FILE variable again after deleting
Modified Script below works for me fine on rasberry
`#!/bin/bash
echo $$
sleep 10s
LOG_FILE=$HOME/.kodi/temp/kodi.log
rm $LOG_FILE 2> /dev/null

/usr/lib/kodi/kodi.bin --standalone &

sleep 5s
LOG_FILE=$HOME/.kodi/temp/kodi.log

while read line ; do
if [[ $line == "application stopped" ]] ; then
echo "Killing kodi"
break
fi
done < <(tail --pid=$$ -f -n0 $LOG_FILE)

killall kodi.bin

sleep 5
fbset -depth 8 && fbset -depth 16
sleep 1s
xrefresh
`

Jeroen52 commented Jun 8, 2016

@aperezm-vlex's script works, makes the desktop functional but leaves black blocks.
@GeorgeBrendanDoyle's script doesn't work for me, but I have used the last few lines of his script to make one that does work for me.

#!/bin/bash

LOG_FILE=$HOME/.kodi/temp/kodi.log

rm $LOG_FILE 2> /dev/null

/usr/lib/kodi/kodi.bin --standalone &

while [[ ! -f $LOG_FILE ]] ; do
    sleep 1s
done

while read line ; do
        if [[ ${line} =~ "application stopped" ]] ; then
            echo "Killing kodi"
        break
    fi
done < <(tail --pid=$$ -f -n0 $LOG_FILE)

killall kodi.bin

sleep 5
fbset -depth 8 && fbset -depth 16
sleep 1s
xrefresh

rjwestman commented Dec 1, 2016 edited

none of the scripts posted work for me. I need to reboot. After using xrefresh ill get an error:
unable to open display ''

This one however worked for me:

#!/bin/bash
fbset_bin=`which fbset`
xset_bin=`which xset`
xrefresh_bin=`which xrefresh`
if [ ! -z $fbset_bin ]; then
  DEPTH2=`$fbset_bin | head -3 | tail -1 | cut -d " " -f 10`
  echo "found depth2: $DEPTH2"
fi
echo "kodi params: $@"
kodi
sleep 2
if [ ! -z $fbset_bin ]; then
  if [ "$DEPTH2" == "8" ]; then
    DEPTH1=16
  else
    DEPTH1=8
  fi
  echo "switching from $DEPTH1 to $DEPTH2"
  $fbset_bin -depth $DEPTH1 > /dev/null 2>&1
  sleep 2
  $fbset_bin -depth $DEPTH2 > /dev/null 2>&1
  sleep 2
fi
if [ ! -z $xset_bin ] && [ ! -z $xrefresh_bin ]; then
  if [ -z $DISPLAY ]; then
    DISPLAY=":0"
  fi

  $xset_bin -display $DISPLAY -q > /dev/null 2>&1
  echo "display check for $DISPLAY is $?"
    if [ "$?" == "0" ]; then
      echo "refreshing"
      $xrefresh_bin -display $DISPLAY > /dev/null 2>&1
    fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment