My Ubuntu Based XBMC/HTPC with full autostartup
#1
After a long haul with MythTV... I'm very pleased to have switched to XBMC.. Nice work guys! So.. to contribute a bit, I thought I'd provide my little tricks to running XBMC on my dedicated Ubuntu (Intrepid) HTPC. I pulled this info from various threads on here, and other sources.

PC Details:
Ubuntu Intrepid
XBMC 8.10
P4 1.6G
256M Ram (yes.. that's right... only 256! time for an upgrade)
40G Seagate Barracuda Hard Drive
GeForce 6200 AGP
Serial IR receiver
(Not a major powerful machine, but it's enough and it's very very quiet)

Assumption:
- You already have Ubuntu installed and running.
- You already have installed and configured your video card
- Your xorg server is correctly setup and working.
- Your LIRCD is running, and your remote is programed in.

For Reference, here is my "Monitor" and "Device" section of my xorg.conf that I had to tweek to work with my 1st gen Sony SXRD (1080i) and my nVidia GForce6200
Code:
Section "Device"
        Identifier      "NVIDIA GeForce 6200"
        Driver          "nvidia"
        Busid           "PCI:1:0:0"
        Option          "AddARGBVisuals"        "True"
        Option          "AddARGBGLXVisuals"     "True"
        Option          "NoLogo"        "True"
        Option          "NoFlip"        "1"
EndSection

Section "Monitor"
        Identifier      "SXRD"
        Option          "DPMS"
        Option          "UseEDID"       "True"
        Option          "ModeValidation"        "NoVertRefreshCheck"
        Modeline        "1080i"           74.25   1920 2008 2056 2200   1080  1082  1087  1125  interlace
EndSection

I wanted XBMC to startup every time the machine started. I also didn't want to start any sort of window mananger, or desktop or set of widgets and whats-its. No KDE or Gnome. Just X and XBMC. Infact, I don't even have KDE or Gnome installed on this HTPC. NO xdm/gdm/kdm either. None of that stuff.

Dedicated htpc User
First, I created a dedicated "htpc" user that has the proper group associations. This is the complete list of groups. I'm sure not every one is needed, but here it is anyway.
("dialout","cdrom","floppy","audio","dip","video","plugdev","netdev","powerdev").
I also setup this user to run the "bash" shell.

Automatic Login of htpc user
Setup INIT to autologin "htpc" on tty2. I chose tty2 just so I could leave the default tty1 output alone.

Install mingetty
Code:
sudo apt-get install mingetty

Modify the file "/etc/event.d/tty2" Set mingetty to autologin my "htpc" user.
Code:
respawn
#exec /sbin/getty 38400 tty2
exec /sbin/mingetty --autologin htpc tty2
What this does is autologin my "htpc" user on tty2. And. if the user logs out. init will restart it, thus cauising xbmc to restart once again.

To tell INIT to re-execute the tty2, run the following commands (as root).. but wait.. don't do it yet. If you run this now... INIT will autologin to tty2 and just sit there. Thats because the "bash" shell for "htpc" will get started and connected to tty2. But.. just sit there waiting for input. Thats where our custom .bash_profile (see below) comes in.
Code:
initctl stop tty2
initctl start tty2
You'll have to use these commands a few times.

Start X and XBMC on login of htpc user
Now, I needed to write a simple custom "/home/htpc/.bash_profile" to start X on login.
Code:
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty2 ]; then

        LIRCPID=`/bin/pidof lircd`

        # if lircd is running, then start up X.  If not, then seep 4 and exit
        if [ -n "$LIRCPID" ]; then
               /usr/bin/startx
        else
                sleep 5
        fi

        exit

fi
The script checks for the $DISPLAY environment variable, and that we are running on tty2. This will prevent "startx" from running if I ssh or su as this user. If it is indeed tty2, then sleep for 1 second, and execute the "startx" script. This script will start your X server and basically wait until it stops. Once "startx" returns, the "exit" command is executed. "Exit" will log out of the "tty2" bash shell, and force INIT to re-spawn the "tty2". This is what we want. If X or XBMC stops for any reason, INIT will re-start it.!!

Now that X is up and running, a custom "/home/htpc/.xinitrc" file is used to simply start xbmc, and a couple of other little utilities.
Code:
export set __GL_SYNC_TO_VBLANK=0
irexec &
irxevent &
xbmc --standalone
#xterm
As you look down the list of programs that get started by X, you'll see they all end with the "&" character except for xbmc. This is a normal tactic to keep X running and waiting for a specific program to terminate before X termiates. So long as xbmc is running, X stays running. The #xterm at the bottom is for testing. If you comment out xbmc, and uncomment xterm, then the xterm will start instead of xbmc.

A little cheat to force a restart with my Remote
Sometimes... xbmc stops responding Sad When that happens I have a button on my "Harmony" remote setup to force X to terminate, and thus force a full restart of the xbmc process. My remote has a custom button labeled "restart"

A custom /home/htpc/.lircrc
Code:
begin
        prog = irexec
        button = restart
        config = pkill -9 X
end

begin
        prog = irexec
        button = E
        config = sudo eject -r
end

begin
        prog = irxevent
        button = rew
        config = Key comma xbmc.bin
end

When the user hit's the "restart" button "X" is killed with extreme prejudice!!
This results in the INIT daemon restarting tty2


Ok... there ya go. I know this is not crystal clear to everyone. Hopefull I can clean up the details as questions arise about how it all works. I just hope it's useful to everyone!

Cheers
Shane.
Reply
#2
After snooping around in here more.. I found this thread
http://forum.xbmc.org/showthread.php?tid=38473
Think I'll do a little switching around of my stuff based on that thread. Similar to mine, but cleaner.
Reply
#3
Just a small update.
I decided to go for a SVN build of XBMC... made a drastic improvement in it's stability on my system!
I also tried the "Media Stream" skin.. WOH! That is easily the nicest skin in the bunch (in my humble opinion).

Just wanted to also thank the XBMC crew for putting together a fantastic bit of software! And to think I started with a Windoz based HTPC running ZoomPlayer!! What a progression to XBMC!
Reply
#4
thanks, very helpful :-)
Reply

Logout Mark Read Team Forum Stats Members Help
My Ubuntu Based XBMC/HTPC with full autostartup0