Kodi Community Forum

Full Version: Starting and stopping kodi from a script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What are the commands to start and stop kodi.

The aim is to restart kodi on resume so it'll always start from the home screen when it turns on.

in older versions i would just enter killall xbmc in the resume section of the 99lirc-resume script. This worked OK killing and restarting xbmc on wake up no problems

Ive tried doing the same with kodi, ie killall kodi. which has the desired effect if the system is not playing any thing. But if a movie is playing and the machine is put to sleep before pressing stop, When it awakes again kodi will be at the home screen but you can hear the movie still playing.

Any ideas ?

Cheers
killall kodi.bin
"killall kodi.bin" does nothing. where as "killall kodi" will kill and restart kodi.
But if a movie is playing, when the command is executed then it will restart kodi, but the audio of the movie is still playing when it wakes....wierd

Does kodi use an external player that also needs stopping ?
The correct way to stop would be to use kodi-send
create a file named "01-restart.power" in sleep.d with

Code:
#!/bin/sh
case "$1" in
   pre)
     ;;
   post)
     systemctl restart kodi
     ;;
esac

-->
http://openelec.tv/forum/107-suspend-and...mitstart=0
http://openelec.tv/forum/107-suspend-and...-on-resume
(2017-01-22, 01:30)nickr Wrote: [ -> ]The correct way to stop would be to use kodi-send

Are you familiar with this kodi-send?
Ive managed to install the correct version. from an SSH terminal it says its sent the command, but nothing happens.
I type kodi-send --action=Quit leaving the out the host and port which then should default to localhost.
Not sure what's going wrong here.

Thanks for your time.

(2017-01-22, 01:55)john.cord Wrote: [ -> ]create a file named "01-restart.power" in sleep.d with

Code:
#!/bin/sh
case "$1" in
   pre)
     ;;
   post)
     systemctl restart kodi
     ;;
esac

-->
http://openelec.tv/forum/107-suspend-and...mitstart=0
http://openelec.tv/forum/107-suspend-and...-on-resume

Before messing about making scripts etc Ive tried just giving the command "systemctl restart kodi" in a ssh terminal window and it just give -bash: systemctl: command not found
I may have missed it, but which OS are you using?
originally installed from kodibuntu 14 64bit, then kodi updated to Jarvis.

Code:
kodi@kodi-64:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.1 LTS - KODIbuntu
Release:        14.04
Codename:       trusty
Got kodi-send working. remote control in kodi settings was disabled.
Now just got to try and put it together to do what I want.

Thanks for all your help.
How are you starting kodi to begin with? Recommend a systemd service unit that should handle this for you.
Thanks, but its all sorted now.
The system will now suspend and resume from both; remote and case button, returning to the home screen on resume, with the added bonus of book marking your position if you happen to suspend in the middle of a movie.

Thanks to kodi-send and thanks again nickr for pointing it out.
Cheers, glad it worked out.