Archlinux xinitrc, inittab (and surroundings)
#1
Question 
I followed the guide to install xbmc on arch for most of its parts. I have an almost perfectly working zotac itx system now. What I would like to change is the way xbmc is started and re-started: doing it like in the guide, it's impossible to turn xbmc off and do something else (on X or not). In other words, my system resurrects xbmc whatever the reason for it not being running...
Can somebody suggest a more elegant way - like xbmc-live does in ubuntu?
Reply
#2
I cant see any reason why you couldnt do it exactly like live xbmc-live. Place a daemon script in /etc/rc.d/xbmc and add to rc.conf daemon list. Then change the runXBMC.sh script to use .xinitrc instead of .xsession. I seem to remember doing this some time ago. I'll see if I can dig up the scripts. Give me a mo.

But you also got to ask yourself, Do you really want to drop back into an X session? If you do then its probably better to log into a WM of some description and then auto start xbmc. If your after a cool Windows manager thats light and relatively easy to set up, try LXDE.
HW : Multiple Asrock 330HT + NAS
SYS: xbmc-live 10.0
Reply
#3
Zeppstar Wrote:I cant see any reason why you couldnt do it exactly like live xbmc-live. Place a daemon script in /etc/rc.d/xbmc and add to rc.conf daemon list. Then change the runXBMC.sh script to use .xinitrc instead of .xsession. I seem to remember doing this some time ago. I'll see if I can dig up the scripts. Give me a mo.
Yes please, thanks!!
Quote:But you also got to ask yourself, Do you really want to drop back into an X session? If you do then its probably better to log into a WM of some description and then auto start xbmc. If your after a cool Windows manager thats light and relatively easy to set up, try LXDE.
I chose blackbox. The reason is that I want to be able to launch (e.g.) firefox and mame without focus problems etc. I've done that already in ubuntu. In other occasions I just needed to debug or change something but was not able because of the never dying xbmc + X.
Reply
#4
Provides xbmc daemon
save in /etc/rc.d/ and make executable (#chmod +x xbmc)
save as 'xbmc'
place 'xbmc' in rc.conf as daemon

Code:
#!/bin/sh

### BEGIN INIT INFO
# Provides:          xbmc
# Required-Start:    $local_fs $network $remote_fs
# Required-Stop:     $local_fs $network $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Description:       Start and Stop XBMC

#/etc/rc.d/xbmc

#. /lib/lsb/init-functions

do_start()
{
        ##Reset Audio  - only required if PCM audio drops out after xbmc crash
        ##Uncomment following if required
        #iecset audio on

        log_action_begin_msg "Configuring system and starting XBMC"
        
        # Usplash specific to Ubuntu - need Arch equivilent
        # if usplash is running, make sure to stop it now, yes "start" kills it.
        # if pidof usplash > /dev/null; then
        #       DO_NOT_SWITCH_VT=yes /etc/init.d/usplash start
        # fi
        /usr/bin/runXBMC.sh &
        log_action_end_msg 0
}

do_stop() {
        touch /tmp/noRestartXBMC
        killall Xorg xbmc.bin
}

case "$1" in
start)
        do_start
        ;;
stop)
        do_stop
        ;;
restart|force-reload)
        do_stop
        do_start
        ;;
*)
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
        exit 3
        ;;
esac

exit 0

Two thing to notice. lsb-release is commented out due to arch not installing by default. Use aur to install and uncomment if required.
Usplash is ubuntu's default way. This section is commented out.
HW : Multiple Asrock 330HT + NAS
SYS: xbmc-live 10.0
Reply
#5
provides runXBMC.sh (chmod +x runXBMC.sh)
save in /usr/bin/runXBMC.sh

Code:
#!/bin/bash

if [ "$(pidof X)" ] ; then
        /usr/share/xbmc/xbmc.bin  --standalone
        exit
fi

while true
do
        echo "#!/bin/bash" >  /home/xbmc/.xinitrc
        echo "/usr/share/xbmc/xbmc.bin  --standalone" >>  /home/xbmc/.xinitrc

        echo "case \"\$?\" in" >>  /home/xbmc/.xinitrc
        echo "    0 ) # Quit" >>  /home/xbmc/.xinitrc
        echo "        touch /tmp/noRestartXBMC" >> /home/xbmc/.xinitrc
        echo "        break ;;"  >>  /home/xbmc/.xinitrc
        echo "    64 ) # Shutdown System"  >>  /home/xbmc/.xinitrc
        echo "        sleep 10 ;;"  >>  /home/xbmc/.xinitrc
        echo "    65 ) # Warm Reboot"  >>  /home/xbmc/.xinitrc
        echo "        echo "Restarting XBMC ..." ;;"  >>  /home/xbmc/.xinitrc
        echo "    66 ) # Reboot System"  >>  /home/xbmc/.xinitrc
        echo "        sleep 10 ;;"  >>  /home/xbmc/.xinitrc
        echo "     * ) ;;"  >>  /home/xbmc/.xinitrc
        echo "esac"  >>  /home/xbmc/.xinitrc

        chown xbmc:xbmc /home/xbmc/.xinitrc

        if [ "$(whoami)" == "root" ] ; then
                su xbmc -c "startx -- -br > /dev/null 2>&1" -l
        else
                startx -- -br > /dev/null 2>&1
        fi

        if [ -e /tmp/noRestartXBMC ] ; then
                rm /tmp/noRestartXBMC
                rm /home/xbmc/.xsession
                break
        fi

        #sleep 2
done

Few gotchas here. Assumes user xbmc. Assumes xbmc is installed to /usr/share/xbmc.
You may need to change this pathand or user accordingly. I cant test this script as I dont currently have an Arch / xbmc install. I hope this at lease shows you how it can be done. It may also be useful to download the xbmc-live ubuntu package and unarchive so you can take a little peek and compare.

You'll need to revert your inittab back to default and set run level to 3.

Let me know how you go with it.

If it does work, you should be able to exit out of xbmc. You can also stop|start|restart xbmc via ssh with

# /etc/rc.d/xbmc stop | start | restart
HW : Multiple Asrock 330HT + NAS
SYS: xbmc-live 10.0
Reply
#6
It also occured to me that you could just change you inittab line from respawn to once

Code:
x:5:respawn: ...

to

Code:
x:5:once: ...

This should stop the never ending restart. To re-start due to crash / exit, just login in and type startx
HW : Multiple Asrock 330HT + NAS
SYS: xbmc-live 10.0
Reply

Logout Mark Read Team Forum Stats Members Help
Archlinux xinitrc, inittab (and surroundings)0