[HOWTO] Start kodi at boot instead of GUI

Post Reply
olingerc
Posts: 28
Joined: Fri Jun 17, 2016 3:29 pm
languages_spoken: english
ODROIDs: C2
Contact:

[HOWTO] Start kodi at boot instead of GUI

Unread post by olingerc » Wed Jul 06, 2016 5:46 am

LibreELEC is a great project, but for people that want to run additional software such as web servers (node, apache, ...) or databases (mongodb, postgresql, ...) it is useful to have the whole ubuntu distro but not start the whole mate desktop or lighdm but only kodi. I am sure one can do this from an ubuntu server like installation but I wanted to start from the supported ubuntu image. This howto was largely inspired from the kodi wiki: http://kodi.wiki/view/HOW-TO:Autostart_Kodi_for_Linux.

This guide was tested on a stock ubuntu installation from Hardkernel (v 2.0) with all updates installed. I had to fiddle with the resolution in boot.ini in order to get my screen recognized. So, here it is:

1. Disable starting the display manager at boot:

Code: Select all

sudo systemctl disable display-manager.service
2. Create a dedicated user for kodi. This user has its own home folder for the .kodi configuration files and belongs to certain groups to get necessary permissions.

Code: Select all

sudo adduser --disabled-password --disabled-login --gecos "" kodi
sudo usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input,netdev kodi
3. Install legacy xserver to allow running kodi from the terminal without a display manager

Code: Select all

sudo apt-get install xserver-xorg-legacy
4. Configure xserver to give permissions to normal non-root user. Choose 'Anybody'

Code: Select all

sudo dpkg-reconfigure xserver-xorg-legacy
Also in /etc/X11/Xwrapper.config, add at the end of the file

Code: Select all

needs_root_rights=yes
You can now already test if it works by manually starting kodi:

Code: Select all

sudo /usr/bin/xinit /usr/bin/dbus-launch --exit-with-session /usr/bin/kodi-standalone -- :0 -nolisten tcp vt7
5. To run at boot, create a systemd service: /etc/systemd/system/kodi.service, with the following content (the words in brackets need their own lines. I'm not sure how to format correctly in the code block below)

Code: Select all

[Unit]
Description = Kodi Media Center

# if you don't need the MySQL DB backend, this should be sufficient
After = systemd-user-sessions.service network.target sound.target

# if you need the MySQL DB backend, use this block instead of the previous
# After = systemd-user-sessions.service network.target sound.target mysql.service
# Wants = mysql.service

[Service]
User = kodi
Group = kodi
Type = simple
#PAMName = login # you might want to try this one, did not work on all systems
ExecStart = /usr/bin/xinit /usr/bin/dbus-launch --exit-with-session /usr/bin/kodi-standalone -- :0 -nolisten tcp vt7
Restart = on-abort
RestartSec = 5

[Install]
WantedBy = multi-user.target
6. Enable on boot

Code: Select all

sudo systemctl enable kodi.service
7. Reboot and rejoice

Additionally
- Add shutdown/reboot to power menu (taken from https://trick77.com/how-to-install-kodi ... diacenter/
Create /etc/polkit-1/localauthority/50-local.d/custom-actions.pkla with:

Code: Select all

[Actions for kodi user]
Identity=unix-user:kodi
Action=org.freedesktop.upower.*;org.freedesktop.consolekit.system.*;org.freedesktop.udisks.*;org.freedesktop.login1.*
ResultAny=yes
ResultInactive=yes
ResultActive=yes
I was happy that my remote worked out of the box, as well as NFS, so for me this is a perfect setup. Also, it should be reversible by simply disabling the kodi service and enabling the display-manager again.

Have fun !
Last edited by olingerc on Sat Jul 23, 2016 2:38 pm, edited 3 times in total.

stmicro
Posts: 235
Joined: Tue Apr 28, 2015 4:23 pm
languages_spoken: english, chinese
ODROIDs: Many Odroids and Rpis.
Location: shenzhen china
Contact:

Re: [HOWTO] Start kodi at login instead of GUI

Unread post by stmicro » Wed Jul 06, 2016 10:45 am

Very helpful instruction. It looks like a KodiBuntu. :) I gonna try it this weekend.
I hope the dynamic refresh rate option works well.

oduesp
Posts: 8
Joined: Tue Jul 05, 2016 5:47 pm
languages_spoken: english
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by oduesp » Mon Aug 08, 2016 12:03 am

Where did you get your kodi pkg ?
If I follow your instruction on a fully updated official ubuntu (from hard kernel, I mean. Using an official eMMC 'linux' card) and install kodi from the standard repo.
I get a black screen (but with a bleep sound) and the kodi.log get spammed with this:
11:00:09 T:548366213120 ERROR: GetCharacter: Unable to cache character (out of memory?)
11:00:09 T:548366213120 ERROR: Invalid GUI Shader selected - [guishader_frag_fonts.glsl]

I think I must install kodi from a different repo, am I right or no ?

oduesp
Posts: 8
Joined: Tue Jul 05, 2016 5:47 pm
languages_spoken: english
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by oduesp » Mon Aug 08, 2016 1:43 am

I add that the first error message from kodi's log is:
ERROR: failed to get egl display

Googling this tell me to run an "odroid-utility" but it's decade old so I'm kind of lost here :(

olingerc
Posts: 28
Joined: Fri Jun 17, 2016 3:29 pm
languages_spoken: english
ODROIDs: C2
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by olingerc » Mon Aug 08, 2016 3:16 am

oduesp wrote:Where did you get your kodi pkg ?
If I follow your instruction on a fully updated official ubuntu (from hard kernel, I mean. Using an official eMMC 'linux' card) and install kodi from the standard repo.
I get a black screen (but
Hmmm, I used the preinstalled kodi package but did reinstall the official image on my eMMC before doing this. I havent updated since a few weeks so I hope no breaking changes were introduced.

oduesp
Posts: 8
Joined: Tue Jul 05, 2016 5:47 pm
languages_spoken: english
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by oduesp » Mon Aug 08, 2016 5:49 am

Strange. I've read here and there that you should not use the official repo's kodi as it's meant to be launch inside a DE (mate here), and that if you want a standalone kodi you should use a "framebuffer" version of it.
Whatever, the instructions above dont work anymore on a fresh and pristine ubuntu installation from HC :(

Isn't there anyone that can enlight us here ? Or is this board already obsolete (or everybody moved to LE) ?

rpcameron
Posts: 278
Joined: Sat Apr 30, 2016 7:24 am
languages_spoken: english
ODROIDs: C2
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by rpcameron » Mon Aug 08, 2016 11:34 am

You can launch the X version of Kodi by starting it via `/usr/bin/xinit /usr/bin/kodi`, or you can use the /usr/bin/kodi-standalone script that basically does the same thing.

It does not need to be run from a DE, just an X session.

stfNL
Posts: 12
Joined: Sun Aug 07, 2016 7:47 am
languages_spoken: English, Nederlands
ODROIDs: C2
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by stfNL » Wed Aug 10, 2016 5:12 pm

LibreELEC is a great project, but for people that want to run additional software such as web servers (node, apache, ...) or databases (mongodb, postgresql, ...) it is useful to have the whole ubuntu distro but not start the whole mate desktop or lighdm but only kodi.
Exactly my thoughts! Thanks for writing this HOW-TO.

filius.martis
Posts: 2
Joined: Sun Sep 11, 2016 5:44 pm
languages_spoken: english, german
ODROIDs: C2 2Ghz@1.5Ghz :-D
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by filius.martis » Wed Sep 14, 2016 2:23 am

olingerc wrote:LibreELEC is a great project, but for people that want to run additional software such as web servers (node, apache, ...) or databases (mongodb, postgresql, ...) it is useful to have the whole ubuntu distro but not start the whole mate desktop or lighdm but only kodi.
Thank you so much, your guide was exactly what I was looking for! It works well for me with my new C2 and a fresh install of ubuntu64-16.04lts-mate-odroid-c2-20160525.img from http://de.eu.odroid.in/ubuntu_16.04lts.

Unfortunately I couldn't get kodi to run on ubuntu64-16.04-minimal-odroid-c2-20160815.img adapting your guide from above. I have no idea what packages are absolutely essential to have kodi standalone running with all the decoding features availiable. If someone could point this out, I would really prefer the minimal installation as a base for my setup.

Best regards
Martin

rockla
Posts: 224
Joined: Sat Dec 27, 2014 6:50 pm
languages_spoken: english
ODROIDs: C1,C2
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by rockla » Thu Sep 22, 2016 11:56 am

Still looking for some help on getting kodi running on minimal image

rizo
Posts: 1
Joined: Fri Sep 23, 2016 9:12 am
languages_spoken: english
ODROIDs: C2
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by rizo » Mon Oct 17, 2016 5:33 am

rockla wrote:Still looking for some help on getting kodi running on minimal image
i just got this working on ubuntu 16.04 minimal image. whats the error youre getting? i'll check my cli history to see if i can help but have you tried the following packages?

Code: Select all

apt-get install xserver-xorg-video-mali mali-x11 aml-libs

acca
Posts: 7
Joined: Mon Oct 31, 2016 10:01 pm
languages_spoken: english
ODROIDs: ODROID C2
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by acca » Mon Oct 31, 2016 10:09 pm

Hi,

I have applied this procedure and it works well if adding

Code: Select all

apt-get install  aml-libs
on latest ubuntu mate image.

But i have a problem, if if run top under a VNC session, i can see that Xorg consumes 85% Cpu and kodi 25%

I'd like to use my odroid to run python scripts via cron every hour and sometimes use kodi to watch videos.

The problem is that kodi runs even when my Tv is off, so my C2 is loaded everytime.

Do you have a solution please ?

Sorry for my bad English, i hope you understand my problem.

User avatar
mad_ady
Posts: 5096
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1
Location: Bucharest, Romania
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by mad_ady » Mon Oct 31, 2016 10:31 pm

To reduce the load/heat generated by Kodi make sure to turn off the RSS feed that goes in the bottom. Any movement causes the CPU/GPU to be used to re-render the OSD and that causes higher CPU load.
Does Xorg consume the same load when you are not logged in via VNC (e.g. just by ssh)?

acca
Posts: 7
Joined: Mon Oct 31, 2016 10:01 pm
languages_spoken: english
ODROIDs: ODROID C2
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by acca » Mon Oct 31, 2016 10:36 pm

I don't know, i have just reloaded the backup image i made before using this topic procedure.

But with no kodi started, i don't see Xorg in the top list.

Do you think loading kodi under WM will cause lower cpu usage ?

Thanks

acca
Posts: 7
Joined: Mon Oct 31, 2016 10:01 pm
languages_spoken: english
ODROIDs: ODROID C2
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by acca » Mon Oct 31, 2016 11:49 pm

I have found the cause of kodi's high cpu usage.

When playing a video, cpu usage is very low. I think because hardware rendering is used.
When i stop playing, kodi returns to my video list, cpu usage is around 25-30% i think it's because of title text scrolling wich is rendered by cpu and not gpu.

is there a way to stop text scrolling after a certain time ?

I have tried to set screensaver to "black" in the settings, the screen becomes black after 3 minutes but cpu is still high.

User avatar
mad_ady
Posts: 5096
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1
Location: Bucharest, Romania
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by mad_ady » Tue Nov 01, 2016 2:25 pm

Is the text in the bottom of the screen in the main menu or is it the film's name?

acca
Posts: 7
Joined: Mon Oct 31, 2016 10:01 pm
languages_spoken: english
ODROIDs: ODROID C2
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by acca » Tue Nov 01, 2016 3:40 pm

The film's name

User avatar
mad_ady
Posts: 5096
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1
Location: Bucharest, Romania
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by mad_ady » Tue Nov 01, 2016 3:58 pm

You can try a different display layout inside Kodi to give the film's name more room...

User avatar
noahphense
Posts: 21
Joined: Sun Dec 04, 2016 4:14 am
languages_spoken: english
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by noahphense » Wed Dec 21, 2016 9:29 am

great method.. more people should try this method, they would love it

it does go back to the xbmc days.. where it was running as a service on linux
Last edited by noahphense on Sat Dec 31, 2016 2:57 am, edited 1 time in total.

checktravis
Posts: 6
Joined: Tue Sep 13, 2016 10:52 pm
languages_spoken: english
ODROIDs: odroid-c2
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by checktravis » Fri Dec 30, 2016 4:50 am

I have a blinking cursor over kodi, looks like the terminal prompt,

Found this http://raspberrypi.stackexchange.com/qu ... ying-video
and, as suggested, this solves it (ssh'd in):

Code: Select all

sudo sh -c "TERM=linux setterm -foreground black -clear all >/dev/tty0"
but when i tried adding to /etc/rc.local it doesn't seem to take effect.

here is the exe line from my systemctl script:

Code: Select all

ExecStart = /usr/local/bin/kodi-standalone

User avatar
mad_ady
Posts: 5096
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1
Location: Bucharest, Romania
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by mad_ady » Fri Dec 30, 2016 3:22 pm

There's a consoleblank boot.ini bootargs parameter that should do the same thing

rpcameron
Posts: 278
Joined: Sat Apr 30, 2016 7:24 am
languages_spoken: english
ODROIDs: C2
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by rpcameron » Fri Dec 30, 2016 3:54 pm

You know, you can always modify the service unit to have a ExecStartPre= in its [Service] section to run a command/script before executing whatever is in your ExecStart= line.

emveeha
Posts: 2
Joined: Fri Dec 16, 2016 5:37 am
languages_spoken: english
ODROIDs: C2
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by emveeha » Thu Jan 12, 2017 12:44 pm

Thank you. Sadly there is no sound when I install the hifishield with this script: http://forum.odroid.com/viewtopic.php?f=118&t=24415.

If I uninstall sound comes back. Can someone help me out?

puppinoo
Posts: 17
Joined: Sun Jan 18, 2015 2:07 am
languages_spoken: english
Contact:

Re: [HOWTO] Start kodi at boot instead of GUI

Unread post by puppinoo » Tue Feb 07, 2017 2:53 am

EDIT: Looking around I think I solved using sudo dpkg-reconfigure lightdm
Thanks anyway and sorry for bothering.

Hi,
I tried to follow the HowTo
it sorta worked but the instruction 'sudo systemctl disable display-manager.service' probably removed the .service file su now if I want to go back and try to execute sudo systemctl enable display-manager.service it gives me a 'file not found' exception. if anyone could be so kind to provide me a copy or tell me how I can regenerate it and make it a way that it's not deleted at next disable execution (i'm really sorry if these are standard procedures and mine are just newbie and bothering questions).

Thanks.

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 1 guest