2011-05-05, 14:31
I wanted to use see if XBMC could be powered by my PC, while letting me use it normally. Most PCs have enough power for video decoding and web surfing at the same time... My PC is most often on when I want to watch a movie, and it is close enough to the TV to plug it with HDMI.
So I investigated on making it work on dualscreen : XBMC running on secondary screen (through HDMI), and Ubuntu still usable on primary screen (through DVI or VGA).
My PC has an Intel HD Graphic card (Core i5 650), and runs Ubuntu 10.04 (64-bit). I use XBMC 10.1 (Dharma).
I now have something useable and wanted to share my little experience :
XBMC on secondary screen (with Intel graphics card)
I read some posts talking of DISPLAY=:0.1 commands, but it does not seem to work this way on a single Intel Graphic card.
I had to configure XBMC to run in windowed mode (that must configured inside the GUI of XBMC), and make a script to move it to secondary screen.
It uses xrandr to activate HDMI2 (this is the name of my HDMI output. HDMI1 is in fact the DVI output that I use for my main screen).
My TV only handles 720p, so I also chose this resolution instead of 1080p
You might adjust all these settings depending on your hardware/configuration (run xrandr on command-line to see which outputs you have)
After activating HDMI2, the script launches xbmc in the background, wait for its window to appear, then moves it to the secondary screen (my main screen has a resolution of 1600x1200, that's why I need to move it with 1600 pixels on the right). I also resize it to 800x600 so that it fits inside the TV screen.
Then I change it to fullscreen. These window movements are made with wmctrl, which should be installed first :
Use HDMI sound
The HDMI sound does not work with the standard kernel of ubuntu 10.04 (2.6.32.x), but it works with the one of ubuntu 10.10 (2.6.35.x). I installed a version backported for lucid : 2.6.35-25.44~lucid1
For more info, see http://doityourselfhtpc.wordpress.com/20...-and-xbmc/
I did not try to make hardware acceleration work on 10.04 : I'll wait until my next ubuntu upgrade.
For XBMC to use the HDMI output for sound, I had to set the following values :
sound output : HDMI
custom hardware : plughw:0,3
passthrough : hdmi
This way, the sound from XBMC goes to the TV (except for the navigation sounds, but it's not a big problem), and all the other sound of the system goes to the standard sound output of the PC.
Use XBMC and Ubuntu at the same time
With only one X session, the keyboard and mouse are shared between the two screens.
My solution was to use a wiimote to control XBMC : it does not emulate keyboard keys but directly XBMC events. This way, it does not interact with the main screen, and it still works if the XBMC window does not have the focus.
Unfortunately, the xbmc-wiiremote tool currently has issues on a 64-bit (multiple deconnections, and events sent too fast). So I had to recompile it from git : running make in that directory https://github.com/xbmc/xbmc/tree/master.../WiiRemote should give you an executable called "WiiUse_WiiRemote" that you can use instead of xbmc-wiiremote
Disable Compiz
XBMC works with Compiz (at least for my config), but I noticed that it slows down XBMC videos. Even on my Core i5, it makes them jerky : it's really annoying. So the script disables it before launching XBMC
Disable screensaver/powersaving/standby mode
The script tries to disable all the things that can disturb XBMC.
For that to work, it has to save the values of these settings, change them while XBMC is running, and put it back after XBMC is stopped.
For that to work, I also use wmctrl to check if XBMC is still running or not. I poll it every second.
There is a drawback of this method : in some cases (if the computer hangs, in particular), the values will not be put back and the powersaving parameters will be kept disabled. So you should keep these values somewhere in case of you have to set them manually
Put BOINC in standby mode
The script tests if BOINC is installed, and put in standby mode if it is. After XBMC is shut down, it makes it compute again.
That saves some CPU for XBMC
I'm pretty sure this script can be improved : suggestions are welcome.
It is really customized to my context (hardware & software) : you'll probably want to modify it to suit your own needs (consider it as GPL if you want to improve it)
I did not test it on any version of ubuntu, and on any other computer : please give your feedback if necessary
Update April 2012 :
For those who would be interested, I updated the script for Ubuntu 12.04 and Unity, on XBMC 11 Eden.
See post #8 below
So I investigated on making it work on dualscreen : XBMC running on secondary screen (through HDMI), and Ubuntu still usable on primary screen (through DVI or VGA).
My PC has an Intel HD Graphic card (Core i5 650), and runs Ubuntu 10.04 (64-bit). I use XBMC 10.1 (Dharma).
I now have something useable and wanted to share my little experience :
XBMC on secondary screen (with Intel graphics card)
I read some posts talking of DISPLAY=:0.1 commands, but it does not seem to work this way on a single Intel Graphic card.
I had to configure XBMC to run in windowed mode (that must configured inside the GUI of XBMC), and make a script to move it to secondary screen.
It uses xrandr to activate HDMI2 (this is the name of my HDMI output. HDMI1 is in fact the DVI output that I use for my main screen).
My TV only handles 720p, so I also chose this resolution instead of 1080p
You might adjust all these settings depending on your hardware/configuration (run xrandr on command-line to see which outputs you have)
After activating HDMI2, the script launches xbmc in the background, wait for its window to appear, then moves it to the secondary screen (my main screen has a resolution of 1600x1200, that's why I need to move it with 1600 pixels on the right). I also resize it to 800x600 so that it fits inside the TV screen.
Then I change it to fullscreen. These window movements are made with wmctrl, which should be installed first :
Code:
sudo apt-get install wmctrl
Use HDMI sound
The HDMI sound does not work with the standard kernel of ubuntu 10.04 (2.6.32.x), but it works with the one of ubuntu 10.10 (2.6.35.x). I installed a version backported for lucid : 2.6.35-25.44~lucid1
For more info, see http://doityourselfhtpc.wordpress.com/20...-and-xbmc/
I did not try to make hardware acceleration work on 10.04 : I'll wait until my next ubuntu upgrade.
For XBMC to use the HDMI output for sound, I had to set the following values :
sound output : HDMI
custom hardware : plughw:0,3
passthrough : hdmi
This way, the sound from XBMC goes to the TV (except for the navigation sounds, but it's not a big problem), and all the other sound of the system goes to the standard sound output of the PC.
Use XBMC and Ubuntu at the same time
With only one X session, the keyboard and mouse are shared between the two screens.
My solution was to use a wiimote to control XBMC : it does not emulate keyboard keys but directly XBMC events. This way, it does not interact with the main screen, and it still works if the XBMC window does not have the focus.
Unfortunately, the xbmc-wiiremote tool currently has issues on a 64-bit (multiple deconnections, and events sent too fast). So I had to recompile it from git : running make in that directory https://github.com/xbmc/xbmc/tree/master.../WiiRemote should give you an executable called "WiiUse_WiiRemote" that you can use instead of xbmc-wiiremote
Disable Compiz
XBMC works with Compiz (at least for my config), but I noticed that it slows down XBMC videos. Even on my Core i5, it makes them jerky : it's really annoying. So the script disables it before launching XBMC
Disable screensaver/powersaving/standby mode
The script tries to disable all the things that can disturb XBMC.
For that to work, it has to save the values of these settings, change them while XBMC is running, and put it back after XBMC is stopped.
For that to work, I also use wmctrl to check if XBMC is still running or not. I poll it every second.
There is a drawback of this method : in some cases (if the computer hangs, in particular), the values will not be put back and the powersaving parameters will be kept disabled. So you should keep these values somewhere in case of you have to set them manually
Put BOINC in standby mode
The script tests if BOINC is installed, and put in standby mode if it is. After XBMC is shut down, it makes it compute again.
That saves some CPU for XBMC
I'm pretty sure this script can be improved : suggestions are welcome.
It is really customized to my context (hardware & software) : you'll probably want to modify it to suit your own needs (consider it as GPL if you want to improve it)
I did not test it on any version of ubuntu, and on any other computer : please give your feedback if necessary
Code:
#! /bin/bash
# Pass -c as a parameter to disable Compiz while XBMC is running
while getopts "c" optname
do
case "$optname" in
"c")
DISABLECOMPIZ=1
;;
*)
echo "Invalid option: -$optname"
;;
esac
done
shift $((OPTIND-1))
if $(xrandr --prop |grep -q "HDMI2 connected")
then
if [ "$DISABLECOMPIZ" != "" ]
then
echo "Disable Compiz"
metacity --replace &
sleep 3
fi
echo "Activate HDMI2"
# The following two lines can be uncommented if the 1280x720 resolution is not proposed (which seems to be the case for Ubuntu 11.04)
#xrandr --newmode "1280x720" 60.47 1280 1328 1456 1632 720 721 724 741 -HSync +Vsync
#xrandr --addmode HDMI2 1280x720
xrandr --output HDMI1 --auto --primary --output HDMI2 --right-of HDMI1 --mode 1280x720
echo "Prepare wiimote connexion"
killall xbmc-wiiremote
xbmc-wiiremote &
# If you use 64-bit version of Ubuntu, you need to use a recompiled version from git because of a bug in amd64 version
#killall -q WiiUse_WiiRemote
#cd ~/dev/xbmc_wiimote/xbmc/tools/EventClients/Clients/WiiRemote/
#./WiiUse_WiiRemote &
#cd ~
if which boinccmd>/dev/null
then
echo "Put BOINC in standby mode"
# (for 8 hours maximum)
boinccmd --set_run_mode never 28800
fi
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,1600,0,800,600
sleep 1
echo "Force XBMC window to fullscreen"
wmctrl -x -r XBMC Media Center.XBMC Media Center -b toggle,fullscreen
echo "Disable Screensaver"
gconftool-2 --set /apps/gnome-screensaver/idle_activation_enabled --type bool FALSE
echo "Disable PowerManager"
SLEEPDISPLAY=`gconftool-2 --get /apps/gnome-power-manager/timeout/sleep_display_ac`
gconftool-2 --set /apps/gnome-power-manager/timeout/sleep_display_ac --type int 0
SLEEPCOMPUTER=`gconftool-2 --get /apps/gnome-power-manager/timeout/sleep_computer_ac`
gconftool-2 --set /apps/gnome-power-manager/timeout/sleep_computer_ac --type int 0
xset -dpms
# 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 HDMI2"
xrandr --output HDMI2 --off
echo "Kill the process that handles the wiimote"
killall xbmc-wiiremote
#killall WiiUse_WiiRemote
if which boinccmd>/dev/null
then
echo "Re-enable BOINC"
boinccmd --set_run_mode auto
fi
echo "Wait 2 seconds for xrandr to complete"
sleep 2
echo "Re-enable ScreenSaver"
gconftool-2 --set /apps/gnome-screensaver/idle_activation_enabled --type bool TRUE
echo "Re-enable PowerManager"
gconftool-2 --set /apps/gnome-power-manager/timeout/sleep_display_ac --type int $SLEEPDISPLAY
gconftool-2 --set /apps/gnome-power-manager/timeout/sleep_computer_ac --type int $SLEEPCOMPUTER
xset +dpms
if [ "$DISABLECOMPIZ" != "" ]
then
echo "Re-enable Compiz"
compiz --replace &
fi
read -p "Press enter to exit..."
else
echo -e "HDMI2 is not connected"
fi
Update April 2012 :
For those who would be interested, I updated the script for Ubuntu 12.04 and Unity, on XBMC 11 Eden.
See post #8 below