Run X11 app at startup, no DE

I'm trying to figure out the proper way to run an X application at boot. I'm trying to run kodi on an htpc. I do not have a desktop environment installed. I can manually run kodi from the terminal with
Code:
xinit kodi

I'm trying to set up a script in /usr/loca/etc/rc.d to do this at startup. Should I be using xinitrc instead? I don't really understand how it words. I tried reading the script but my shell script knowledge is horrible.

Here is my /usr/local/etc/rc.d/kodi
Code:
#!/bin/sh

. /etc/rc.subr

name="kodi"
rcvar="${name}_enable"
load_rc_config {name}

PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
start_cmd="xinit kodi"
start_precmd="cd /home/htpc"
stop_cmd=":"

: ${kodi_user:=htpc}


run_rc_command "$1"
This fails because of file permissions. I think this is what's going on. Kodi tries to write files at ~/, but this script is working from / and tries to write there instead?
Code:
$ service kodi start


X.Org X Server 1.18.4
Release Date: 2016-07-19
X Protocol Version 11, Revision 0
Build Operating System: FreeBSD 11.0-RELEASE-p12 amd64
Current Operating System: FreeBSD HTPC 11.1-RELEASE FreeBSD 11.1-RELEASE #0 r321309: Fri Jul 21 02:08:28 UTC 2017     root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64
Build Date: 10 October 2017  01:14:51AM

Current version of pixman: 0.34.0
    Before reporting problems, check http://wiki.x.org
    to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
    (++) from command line, (!!) notice, (II) informational,
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Fri Nov 17 19:36:24 2017
(==) Using config directory: "/usr/local/etc/X11/xorg.conf.d"
(==) Using system config directory "/usr/local/share/X11/xorg.conf.d"
Could not init logging classes. Log folder error (/.kodi/temp/)
ERROR: Unable to create application. Exiting
Segmentation fault (core dumped)
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
find: /root/.local: Permission denied
find: /var/audit: Permission denied
find: /var/authpf: Permission denied
find: /var/cron/tabs: Permission denied
find: /var/run/ppp: Permission denied
find: /var/run/tpm: Permission denied
find: /var/run/sudo: Permission denied
find: /var/db/entropy: Permission denied
find: /var/db/ipf: Permission denied
find: /var/db/hyperv: Permission denied
find: /var/db/freebsd-update: Permission denied
find: /var/db/ntp: Permission denied
find: /var/db/samba4/private: Permission denied
find: /var/db/sudo: Permission denied
find: /var/heimdal: Permission denied
find: /var/spool/clientmqueue: Permission denied
find: /var/spool/opielocks: Permission denied
find: /var/spool/dma: Permission denied
find: /etc/ntp: Permission denied
cat: /proc/sys/kernel/core_pattern: No such file or directory
cat: /proc/sys/kernel/core_pattern: No such file or directory
usage: dirname string [...]
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
/usr/local/bin/kodi: cannot create //kodi_crashlog-20171117_193626.log: Permission denied
Crash report available at //kodi_crashlog-20171117_193626.log
xinit: connection to X server lost

waiting for X server to shut down (II) Server terminated successfully (0). Closing log file.
What is the proper way to do this? I want to do this without having to log in at all, just boot straight to kodi.

I tried adding to my rc script:

start_precmd="cd /home/htpc"

and/or

kodi_chdir="/home/htpc"
kodi_chroot="/home/htpc"

It doesn't seem like either one of these does anything.
 
Ok Here's another question. The exit function in kodi does not quite behave as expected. It does not shut down the x-server and close kodi. Kodi just freezes and becomes unresponsive as the X-server stays running. It's not a huge deal as everything else works perfectly so far. But is it possible to change this?
 
pkill X would shut down X although I am unsure how you would call it from Kodi. shutdown -p now would shut down the machine.
 
Back
Top