XBMC Launch Script for Ubuntu 11.04

Being a happy Ubuntu user for a while, I installed XBMC on my HTPC. As this machine is also used as a desktop (it’s in the living room) I wanted a script to launch Ubuntu and place it on the TV that is connected trough HDMI. After trying a bunch of scripts I found on the internet none of them really worked the way I wanted. For starters, Gnome only gives me one desktop to play around with. This script does the following:

  • Disable the power manager
  • Activate HDMI1
  • Start XMBC, move it to the second scren and maximize it
  • Undo the above once XBMC is closed

Off course you will need to change a few parameters to make it work for your case. Your TV might not be connected to HDMI1 and may have a different size for example.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /bin/bash
if $(xrandr --prop |grep -q "HDMI1 connected")
then
    echo "Disable Power Manager"
    gconftool-2 --set --type integer "/apps/gnome-power-manager/timeout/sleep_computer_ac" 0

    echo "Activate HDMI1"
    xrandr --output HDMI1 --left-of HDMI2 --mode 1920x1080
    xrandr --output HDMI2 --auto --primary

    echo "Start XBMC in background"
    killall -s9 -q xbmc.bin
    xbmc &

    echo "Wait for the XBMC window to appear"
    status=0
    while [ $status -eq 0 ]
    do
        sleep 1
        status=`wmctrl -x -l | grep "XBMC Media Center" | wc -l | awk '{print $1}'`
    done

    echo "Move XBMC to secondary screen"
    wmctrl -x -r XBMC Media Center.XBMC Media Center -e 0,0,0,800,600

    sleep 1
   
    echo "Force XBMC window to fullscreen"
    wmctrl -x -r XBMC Media Center.XBMC Media Center -b toggle,fullscreen

    # Wait for the XBMC window to disappear
    status=1
    while [ $status -eq 1 ]
    do
        sleep 1
        status=`wmctrl -x -l | grep "XBMC Media Center" | wc -l | awk '{print $1}'`
    done

    echo "Disable HDMI1"
    xrandr --output HDMI1 --off

    echo "Wait 2 seconds for xrandr to complete"
    sleep 2

    echo "Enable Power Manager (Sleep / 30 Minutes)"
    gconftool-2 --set --type integer "/apps/gnome-power-manager/timeout/sleep_computer_ac" 1800
else
    echo -e "HDMI1 is not connected"
fi

There you go. If you have any suggestions or need help getting this to work on your end feel free to leave a comment!

HDMI Sound Cards

As i am looking into upgrading my Home Theater to support Full HD, one problem that comes up is audio. While most people are just starting to become familiar with optical connections, the industry has already moved beyond that point. Thing like True HD sound use too much bandwidth to transfer over an optical connection.

So where does that leave us? HDMI supports video and audio. The only problem is combining the output from the graphics and sound card into one signal. I was initially looking for a video card with audio-in capabilities but did not find any that supported the newer HDMI 1.3 standard. This solution poses another problem as well: when such card becomes available, it will be very expensive. HDMI capable video cards however, are already available and very well priced.

The solution? HDMI capable sound cards. They have a HDMI input for the video signal from the graphics card and a HDMI output that sends out a combined Audio / Video signal. I have found 2 models already in the works:

Auzentech HDMI X-Tension Sound Card
Asus Xonar AV1

I will post more on them as they get released… and i decide which to buy :)