User avatar
Mequa
Posts: 172
Joined: Sun Sep 09, 2012 9:54 pm
Location: England
Contact: Website

Re: Exit Fix for Kodi Raspbian built

Wed Mar 25, 2015 10:18 pm

I'd also like to see a fix for this. In addition to Michael Gorven's repository, it would be great to have a bugfixed Kodi added to the official Raspbian repos, and maybe even the Pi Store.

Being able to launch and cleanly exit Kodi (without rebooting) running on Raspbian (from either LXDE, EmulationStation, or the command line) would be a very good feature, especially on a Raspberry Pi 2.

Tom_A
Posts: 272
Joined: Fri Dec 06, 2013 8:34 am

Re: Exit Fix for Kodi Raspbian built

Sat Mar 28, 2015 3:14 am

I am thinking that it may now be possible to launch Kodi from within LXDE on a Raspberry Pi 2. I tried it briefly when I first got mine and it seemed to work OK for the limited time testing. I still prefer to be able to exit to lightdm and then launch Kodi from there (It's listed twice now for some reason. That started with the name change to Kodi). I have one Ubuntu box on a core i3 NUC and I also log into Kodi this way on it as well. This auto logs users in only to the Kodi interface and not the full OS, but I can log out and in to Unity when I want to. I'm looking forward to some fixes to this issue as well.

The set of scripts is throwing a "unary operator expected" error from the second script. I'm trying the other script by juppiter89 to see if that works now.

quelcom
Posts: 3
Joined: Mon Apr 06, 2015 2:27 pm

Re: Exit Fix for Kodi Raspbian built

Mon Apr 06, 2015 2:40 pm

Another temporary solution for the black screen problem that does not involve cron jobs is launching Kodi with:

Code: Select all

kodi-standalone && sleep 2 && chvt 2 && chvt1 
This works fairly well for me, since I rarely have a keyboard plugged in (I launch/control Kodi with a remote control) and therefore I could not switch momentarily to another TTY to workaround the problem. The chvt command does just that.

gkreidl
Posts: 6139
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Exit Fix for Kodi Raspbian built

Mon Apr 06, 2015 9:35 pm

quelcom wrote:Another temporary solution for the black screen problem that does not involve cron jobs is launching Kodi with:

Code: Select all

kodi-standalone && sleep 2 && chvt 2 && chvt1 
This works fairly well for me, since I rarely have a keyboard plugged in (I launch/control Kodi with a remote control) and therefore I could not switch momentarily to another TTY to workaround the problem. The chvt command does just that.
That's no solution because Kodi simply hangs (doesn't return).
If you start Kodi and leave it again immediately, it often returns to the normal screen (doesn't crash), but if you do something like playing a movie and then try to close it you'll get the error and Kodi ist blocking.
This is a well known Kodi bug and has been fixed but the fix wasn't backported to 4.1 or even 4.2. A pity.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

quelcom
Posts: 3
Joined: Mon Apr 06, 2015 2:27 pm

Re: Exit Fix for Kodi Raspbian built

Tue Apr 07, 2015 7:23 am

gkreidl wrote:
quelcom wrote:Another temporary solution for the black screen problem that does not involve cron jobs is launching Kodi with:

Code: Select all

kodi-standalone && sleep 2 && chvt 2 && chvt1 
This works fairly well for me, since I rarely have a keyboard plugged in (I launch/control Kodi with a remote control) and therefore I could not switch momentarily to another TTY to workaround the problem. The chvt command does just that.
That's no solution because Kodi simply hangs (doesn't return).
If you start Kodi and leave it again immediately, it often returns to the normal screen (doesn't crash), but if you do something like playing a movie and then try to close it you'll get the error and Kodi ist blocking.
This is a well known Kodi bug and has been fixed but the fix wasn't backported to 4.1 or even 4.2. A pity.
That's true, my bad. I noticed this yesterday night when my solution did not work after playing a video (left with a black screen instead of returning to the original TTY). When I was testing the command successfully I was only opening/closing Kodi.

Hope there is a build of Kodi 15 for Raspbian soon enough.

yonie
Posts: 4
Joined: Tue Apr 14, 2015 7:58 pm

Re: Exit Fix for Kodi Raspbian built

Tue Apr 14, 2015 8:01 pm

i found a fix that actually resolves the black screen upon Kodi exit back to emulationstation. in whatever script you use to start Kodi from Emulationstation, add

Code: Select all

fbset -depth 8 && fbset -depth 16
Here's my Kodi.sh

Code: Select all

#!/bin/bash
kodi
fbset -depth 8 && fbset -depth 16

gkreidl
Posts: 6139
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Exit Fix for Kodi Raspbian built

Wed Apr 15, 2015 6:25 am

Thd kodi-standalone script does exactly that and in a much better way:

Code: Select all

FB_GEOMETRY="$(fbset --show | grep geometry | cut -d' ' -f 6-)"
....
fbset --geometry $FB_GEOMETRY
This does not solve the problem. The black screen is an internal bug of the current kodi versions (it hangs).
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

yonie
Posts: 4
Joined: Tue Apr 14, 2015 7:58 pm

Re: Exit Fix for Kodi Raspbian built

Wed Apr 15, 2015 10:38 am

It seems that there might be two problems then

a) Kodi hangs upon exit
b) Text is no longer visible after exiting Kodi

I'm quite sure the line i mentioned above actually works to address b), but I agree it seems there is a bigger (root) problem not solved which is that Kodi sometimes never exits.

Sorry if i caused any further confusion on this.

gkreidl
Posts: 6139
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Exit Fix for Kodi Raspbian built

Wed Apr 15, 2015 2:35 pm

yonie wrote:It seems that there might be two problems then

a) Kodi hangs upon exit
b) Text is no longer visible after exiting Kodi

I'm quite sure the line i mentioned above actually works to address b), but I agree it seems there is a bigger (root) problem not solved which is that Kodi sometimes never exits.

Sorry if i caused any further confusion on this.
Yes. Problem a) is solved by using kodi-standalone instead of calling kodi directly (and it works with all color resolutions)
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

User avatar
expandables
Posts: 654
Joined: Fri Jun 27, 2014 7:34 pm
Location: Neverland with Michael Jackson

Re: Exit Fix for Kodi Raspbian built

Fri May 01, 2015 9:24 pm

Exit fix use this method instead viewtopic.php?f=66&t=109088&p=750252#p750252
:mrgreen:
By thinking like an engineer you can create a raspberry pi.
Michael Jackson enthusiast.
I got the PI model B, B+ and PI 2 model B.
When will I get the A? I don't know.

davidtuti
Posts: 85
Joined: Tue Oct 22, 2013 6:21 am

Re: Exit Fix for Kodi Raspbian built

Tue May 19, 2015 1:11 pm

Hi,
I have the same problem. My English is very bad. So to fix it the best solution is in the post one no?
Thanks

davidtuti
Posts: 85
Joined: Tue Oct 22, 2013 6:21 am

Re: Exit Fix for Kodi Raspbian built

Tue May 19, 2015 4:57 pm

The problem with black screen for me is not solved.
When I exit of kodi it seem that exitfix find pattern ""Attempted to remove window 10013". But the second script that makes a killall kodi dont kill nothing because I dont have kodi in process.
Any help?
Thanks

Tom_A
Posts: 272
Joined: Fri Dec 06, 2013 8:34 am

Re: Exit Fix for Kodi Raspbian built

Tue May 19, 2015 6:36 pm

davidtuti wrote:The problem with black screen for me is not solved.
When I exit of kodi it seem that exitfix find pattern ""Attempted to remove window 10013". But the second script that makes a killall kodi dont kill nothing because I dont have kodi in process.
Any help?
Thanks
The sudo sh part in the root crontab doesn't work for me either, however it doesn't appear to be necessary as the script already has root since it's running from the root cron. Kodi should still be in your process list, however once it gets to the point where things lock up, it's not using any processing power, so it's not at the top of the list like it is idling at the main menu.

The problem I have now is that I launch Kodi from the LightDM screen and when I kill Kodi it restarts instead of quitting to LightDM. The second exit goes to LightDM if I don't play a video before the second exit since the script doesn't run in that case, but would be nice if I didn't have to do this.

vassiskansa
Posts: 6
Joined: Fri Mar 20, 2015 10:09 am

Re: Exit Fix for Kodi Raspbian built

Wed May 20, 2015 9:46 am

I've the same problem... kodi installed with raspbian on raspberry pi 2... heeeelp!

vassiskansa
Posts: 6
Joined: Fri Mar 20, 2015 10:09 am

Re: Exit Fix for Kodi Raspbian built

Wed May 20, 2015 10:00 am

Hi,
by starting kodi-standalone the problem seems solved, but my sony bravia hdmi tv poweroff even exit button pressed. Why? It's only my problem?
Thank you.
Bye.

hani
Posts: 18
Joined: Mon May 18, 2015 10:11 am

Re: Exit Fix for Kodi Raspbian built

Wed May 20, 2015 11:29 am

vassiskansa wrote:Hi,
by starting kodi-standalone the problem seems solved, but my sony bravia hdmi tv poweroff even exit button pressed. Why? It's only my problem?
Thank you.
Bye.
I still have the exit issue but I did solve the turning tv off issue.

Once in kodi go to SYSTEM > Setting > System > Input Devices > Peripherals and click on CEC Adaptor. From there you change "Devices to power off when stopping Kodi" to None. May need to tweak some other things whilst there too.

vassiskansa
Posts: 6
Joined: Fri Mar 20, 2015 10:09 am

Re: Exit Fix for Kodi Raspbian built

Wed May 20, 2015 12:22 pm

okay, i'll try.
Thank you.

vassiskansa
Posts: 6
Joined: Fri Mar 20, 2015 10:09 am

Re: Exit Fix for Kodi Raspbian built

Wed May 20, 2015 1:58 pm

It works well... thank you.

Tom_A
Posts: 272
Joined: Fri Dec 06, 2013 8:34 am

Re: Exit Fix for Kodi Raspbian built

Thu May 21, 2015 8:24 am

OK, now that I've had some time to really look at the kodi-standalone file, here's my solution.
First, a script in /usr/bin called kodi-exit

Code: Select all

#!/bin/bash

sleep 5
while [ $(pgrep "kodi.bin") ]
do
    if [[ $(tail -1 /home/tomalperin/.kodi/temp/kodi.log | grep "application stopped...") ]]
    then
      /usr/bin/pkill kodi.bin
      mv /home/tomalperin/.kodi/temp/kodi.log /home/tomalperin/.kodi/temp/kodi.old.log
    fi
    sleep 2
done
Next, kodi-standalone needs some fixes. Open up /usr/bin/kodi-standalone in your favorite text editor and find the while loop. Directly above the while loop add this:

Code: Select all

/usr/bin/kodi-exit & #fix black screen exit bug
Now, if you don't want Kodi to reboot when you kill it, you need to find the "else # crash" part of the script and put "LOOP=0" somewhere in there. This will disable the relaunch on kill but will also disable restarting after a crash as well. I commented this as well in my kodi-standalone script so I could find it easily to remove it if I wanted to. "LOOP=0 #Disable restart on crash or kill"

This solution:
1. Exits quickly. No 1 minute wait for the script to run.
2. Does not run while you are not running Kodi.
3. Does not require root to kill Kodi when it misbehaves.
4. Does not relaunch Kodi after you just waited a minute for it to finally exit.

I am using this by launching Kodi from the lightdm menu. If you are launching directly from the console then the little bits about jumping to different consoles might be needed, but I've found I can remove that with no effect to how the script runs. I doubt they are actually running in the script, since the script shouldn't have root privileges they way I'm launching it anyway. I've set "sudo" up to require a password on my RPi 2.

gkreidl
Posts: 6139
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Exit Fix for Kodi Raspbian built

Thu May 21, 2015 9:46 am

That seems to be the best solution so far!
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

davidtuti
Posts: 85
Joined: Tue Oct 22, 2013 6:21 am

Re: Exit Fix for Kodi Raspbian built

Thu May 21, 2015 5:22 pm

These solution works ok for me the first time. The second time that I open kodi when I exit I cant see the terminal other time

Tom_A
Posts: 272
Joined: Fri Dec 06, 2013 8:34 am

Re: Exit Fix for Kodi Raspbian built

Thu May 21, 2015 5:36 pm

davidtuti wrote:These solution works ok for me the first time. The second time that I open kodi when I exit I cant see the terminal other time
If you are not launching from the lightdm menu and instead launching from the console, then I think you want the script to look like this:

Code: Select all

#!/bin/bash

sleep 5
while [ $(pgrep "kodi.bin") ]
do
    if [[ $(tail -1 /home/tomalperin/.kodi/temp/kodi.log | grep "application stopped...") ]]
    then
      /usr/bin/pkill kodi.bin
      mv /home/tomalperin/.kodi/temp/kodi.log /home/tomalperin/.kodi/temp/kodi.old.log
      chvt 2 && sleep 1 && chvt 1
    fi
    sleep 2
done
I think that the console switching part after moving the log makes the console show up properly on additional exits, but it's not necessary when returning to the lightdm screen.

User avatar
fade2gray
Posts: 16
Joined: Fri Apr 24, 2015 2:21 pm

Re: Exit Fix for Kodi Raspbian built

Mon May 25, 2015 12:18 pm

expandables wrote:
vankogt wrote:Here is my working fix.

I start kodi from this script:

#!/bin/bash
kodi -fs && sleep 1 && sudo service lightdm restart
I tried your script and i can confirm that this does not work. :mrgreen:
I tried vankogt's script and can confirm that it does work for me - thank you vankogt. :mrgreen:
(Using the default repository release of Kodi on a pi b2 running raspbian.)

I also edited the 'kodi.desktop' file so that calling Kodi with the raspberry menu or desktop icon will automatically run the script:

Code: Select all

$ sudo nano /usr/share/applications/kodi.desktop
Change:

Code: Select all

Exec=kodi
To:

Code: Select all

Exec=/your/path/to/kodi_exit_fix.sh

Tom_A
Posts: 272
Joined: Fri Dec 06, 2013 8:34 am

Re: Exit Fix for Kodi Raspbian built

Tue May 26, 2015 3:41 pm

fade2gray wrote: I also edited the 'kodi.desktop' file so that calling Kodi with the raspberry menu or desktop icon will automatically run the script:

Code: Select all

$ sudo nano /usr/share/applications/kodi.desktop
Change:

Code: Select all

Exec=kodi
To:

Code: Select all

Exec=/your/path/to/kodi_exit_fix.sh
That is the file for the "raspberry" menu, however it does not apply to the lightdm menu. The lightdm menu has another kodi.desktop file stored in /usr/share/xsessions. You'll also notice that there's an xbmc.desktop file here as well. I'm not sure why when they changed the name they felt it necessary to include this shortcut, but it's the reason kodi is listed twice on the lightdm menu. You can delete this if you only want kodi listed once. I've added some games that are recommended to run without running the GUI here as well by making my own .desktop files.

You might want to try playing a video before exiting Kodi to verify that it is working properly. Kodi will exit without issue for me if I haven't played a video yet, especially if it's just been launched. I'm tempted to try this fix myself, but I think possibly you didn't check whether it works thoroughly enough. If this did work, it only makes sense to me that it would work if you used lightdm to launch Kodi.

User avatar
fade2gray
Posts: 16
Joined: Fri Apr 24, 2015 2:21 pm

Re: Exit Fix for Kodi Raspbian built

Tue May 26, 2015 4:37 pm

Tom_A wrote:You might want to try playing a video before exiting Kodi to verify that it is working properly. Kodi will exit without issue for me if I haven't played a video yet, especially if it's just been launched. I'm tempted to try this fix myself, but I think possibly you didn't check whether it works thoroughly enough. If this did work, it only makes sense to me that it would work if you used lightdm to launch Kodi.
You are absolutely correct - thanks for pointing that out.

I shall now go and crawl under a stone while I consider the consequences of my actions. :oops: :lol:

Return to “General discussion”