Creating a media pc with Gentoo and XBMC

I am using an old broken laptop I have (Samsung N130) to work as a media pc. Its hardware is fairly typical of laptops, and is fully supported by Linux. I like using System Rescue CD to install with, I’m presuming you already have a working knowledge of Gentoo.

  • Intel 915 Video
  • eth0 RTL8101E/RTL8102E
  • wlan0 RTL8192E/RTL8192SE
  • Intel HD Audio

Basic Setup

  1. Boot into System Rescue CD
  2. /etc/init.d/ntp-client start
  3. Follow the basic setup here, stop after the first reboot.
  4. Setup wpa_supplicant if you are using wireless
  5. emerge and setup ntp

Config Tweaks

/etc/make.conf

USE="X gif jpeg png tiff opengl samba dbus gtk alsa aac mp3 wma 
     xvid win32codecs mpeg dvd ogg sdl vcd a52 flac gnutls"
VIDEO_CARDS="intel vesa vga"
INPUT_DEVICES="evdev keyboard mouse synaptics"
MAKEFLAGS="-j2 -l2"
ACCEPT_LICENSE="*"

/etc/portage/package.keywords
media-tv/xbmc ~x86

/etc/portage/package.use
dev-libs/libxml2 python
media-tv/xbmc alsa xrandr udev
sys-fs/udev extras
sys-auth/consolekit policykit
sys-auth/pambase consolekit

Install Packages

These 2 major packages pull in everything you need.

  1. emerge xorg-server
  2. emerge xbmc

Configure

  1. rc-update add alsasound default (make sure to unmute alsa)
  2. rc-update add consolekit default
  3. useradd -m -c “XBMC” xbmc
  4. usermod -G audio,cdrom,cdrw,video xbmc

Create ~xbmc/.xinitrc

exec /usr/bin/dbus-launch \
    --exit-with-session \
     /usr/bin/xbmc-standalone

Create /etc/init.d/xbmc with the following, and add it to the default boot level
#!/sbin/runscript

depend() {
        need dbus
        need consolekit
        need net
        after alsasound
}

start() {
        ebegin "Starting ${SVCNAME}"
        su -l xbmc -c startx > /tmp/xbmc.log 2>&1 &
        eend 0
}

stop() {
        ebegin "Stopping ${SVCNAME}"
        xbmc-send --host=127.0.0.1 --port=9777 --action="XBMC.Quit"
        eend 0
}

If you are using DRI, /usr/share/X11/xorg.conf.d/90-dri.conf
Section "DRI"
    Mode 0660
EndSection

Create /etc/polkit-1/localauthority/50-local.d/custom-actions.pkla
[Actions for xbmc user]
Identity=unix-user:xbmc
Action=org.freedesktop.upower.*;org.freedesktop.consolekit.system.*;org.freedesktop.udisks.*
ResultAny=yes
ResultInactive=no
ResultActive=yes

Alternatively, for newer polkit versions, you’ll need to create a rules script /etc/polkit-1/rules.d/10-xbmc.rules
polkit.addRule( function( action, subject )
{
        if( subject.user == "xbmc" )
        {
                if( action.id.indexOf( "org.freedesktop.udisks." ) == 0
                        || action.id.indexOf( "org.freedesktop.power." ) == 0
                        || action.id.indexOf( "org.freedesktop.consolekit.system." ) == 0 )
                {
                        return "yes";
                }
        }
});

That’s it! Reboot and your good to configure XBMC and watch movies!

This entry was posted in Gentoo. Bookmark the permalink.