XBMC for Linux - Tips and Tricks
#1
Big Grin 
Here are some simple shell scripts that you may find useful. I'm not a particularly strong scripter, so I'm sure these can be greatly improved.

Start/Kill XBMC with the remote control
If you don't have a wireless keyboard, it can be useful to start XBMC with the remote control. XBMC is still in beta, so it can lock up occasionally. When it does, you can SSH in and kill the process, get out that keyboard again and ctrl-alt-backspace, or use the remote to kill the process. The remote is the way to go.

=== 1
Install LIRC, the daemon that receives IR signals from the remote control. In the terminal:
Code:
sudo apt-get install lirc lirc-x liblircclient0

=== 2
To determine what should be placed in the "button" lines in your .lircrc, referenced in section 3:
1) Run "irw" from the terminal. It should appear to hang. If it doesn't, or you get an error message, your LIRC is setup incorrectly.
2) Point your remote at the receiver and press the button you want to assign. The buttons I've used are on the windows MCE remote and unused by XBMC.
3) Hit CTRL-C to exit irw.

=== 3
Put the following in your ~/.lircrc file, replacing the "button" arguments as you like. Create the file if it does not already exist.
Code:
# Start XBMC
begin
prog = irexec
button = RecTV
config = /home/youruser/scripts/startXBMC.sh
end

# Kill XBMC
begin
prog = irexec
button = DVD
config = /home/youruser/scripts/killXBMC.sh
end

=== 4
This script will start the IR daemons. Create it as "/home/youruser/scripts/startIRexec.sh":
Code:
#!/bin/bash

# Test to see if IRXevent is running first, if so kill it, then restart
if ps -ef|grep -v grep|grep -i irxevent
then
ps aux|grep -i youruser|grep -i irxevent |awk '{print $2}'|xargs kill
else
# Do nothing
echo "irxevent already dead!"
fi

# Test to see if IRexec is running first, if so kill it, then restart
if ps -ef|grep -v grep|grep -vi start|grep -i irexec
then
ps aux|grep -i youruser|grep -i irexec |grep -vi start|awk '{print $2}'|xargs kill
else
# Do nothing
echo "irexec already dead!"
fi

#test to see if an instance of irxevent is already running
if ps -ef|grep -v grep|grep irxevent
then
# do nothing
echo "irxevent already running"
else
# start irxevent
irxevent /home/youruser/.lircrc &
fi

#test to see if an instance of irexec is already running
if ps -ef|grep -v grep|grep irexec
then
# do nothing
echo "irexec already running"
else
# start irxevent
irexec -d /home/youruser/.lircrc &
fi

exit

=== 5
To automatically start the IRXevent and IRexec daemons when you login to the desktop, go to the SYSTEM, PREFERENCES, SESSIONS menu. Click "Add", and fill in the following:
Name: Start IR Daemons
Command: /home/youruser/scripts/startIRexec.sh
Comment: whatever you want

Click OK, then the checkbox so it's enabled. This will run the startIRexec.sh script every time you log on to the desktop.

=== 6
Create the following scripts. These actually start and kill XBMC.

/home/youruser/scripts/startXBMC.sh: (replace "youruser" with your user name)
Code:
#!/bin/bash

# Test to see if XBMC is running first
if ps -ef|grep -v grep|grep -i xbmc.bin
then
# Do nothing
echo "XBMC already Running!"
else
# Startup XBMC
xbmc
fi
exit

/home/youruser/scripts/killXBMC.sh:
Code:
#!/bin/bash

# Test to see if XBMC is running first
if ps -ef|grep -v grep|grep -i xbmc.bin
then
# Try a clean kill
ps aux|grep -i youruser|grep -v grep|grep -i xbmc.bin|awk '{print $2}'|xargs kill
echo `date` "Killed XBMC! (soft)" >> /tmp/killXBMC.log
else
echo "XBMC already dead! (soft)"
exit
fi

# takes a second or two to die with the soft kill
sleep 2

# Test to see if it's still running
if ps -ef|grep -v grep|grep -i xbmc.bin
then
# If it's still around, kill it -9
ps aux|grep -i youruser|grep -v grep|grep -i xbmc.bin|awk '{print $2}'|xargs kill -9
echo `date` "Killed XBMC! (hard)" >> /tmp/killXBMC.log
else
echo "XBMC already dead! (hard)"
exit
fi

=== 7
Make the scripts executable.
Code:
chmod +x /home/youruser/scripts/*.sh

=== 8
Log out of the desktop, then log back in. You should be set!

1) Press the button you set to start XBMC (Recorded TV if you used my suggestion). XBMC should start. Start playing a video.
2) Press the button you set to kill XBMC (DVD if you used my suggestion). XBMC should gracefully exit. Your mouse should still work in X windows, if you have one plugged in.
3) Start XBMC back up, start playing a video, then make XBMC lock up. The easiest way is to play a video, go to the video options, and change the interlacing method a couple of notches. Then press the kill button again-- it should hard kill XBMC, instantaneously taking you back to the desktop. Your mouse will likely be inoperable; to fix it just start and stop XBMC again.

Hope this helps, and please post any other tips you've hacked together!
Reply
#2
I started using FreeNX (a much faster remote desktop than VNC) and the remote stopped working. FreeNX actually starts a separate instance of X windows, which re-runs startIRexec.sh. I believe this associates the execution to the freeNX instance, which of course doesn't work. To fix this, remove the kill statements from the beginning of the script.

If you stick with VNC (the built in vino stuff in Ubuntu) use the old script. The preliminary kill is a good thing.

/home/youruser/scripts/startIRexec.sh:
Code:
#!/bin/bash

#test to see if an instance of irxevent is already running
if ps -ef|grep -v grep|grep irxevent
then
# do nothing
echo "irxevent already running"
else
# start irxevent
irxevent /home/youruser/.lircrc &
fi

#test to see if an instance of irexec is already running
if ps -ef|grep -v grep|grep irexec
then
# do nothing
echo "irexec already running"
else
# start irxevent
irexec -d /home/youruser/.lircrc &
fi

exit
Reply
#3
Obviously ripped from PM3, but it looks pretty good. I created my launcher with just a space (" ") as the name, since the icon is fairly descriptive.

Image
Reply
#4
This is a small variant on the above scripts that start and stop XBMC. This script can be bound to one key to start (or restart) XBMC. You'll want to edit the "export USER=elvis" line to set it to your username.

#!/bin/bash

export USER=elvis
export XBMC_HOME=/home/$USER/XBMC/BUILD
export LOG=$XBMC_HOME/restart.log


# Test to see if XBMC is still running
if ps -ef|grep -v grep|grep -i XboxMediaCenter
then
# Send gentle kill signal
killall XboxMediaCenter
echo `date` "Killed XBMC! (soft)" >> $LOG

# takes a second or two to die with the soft kill
sleep 2

# still running? Send hard kill signal
if ps -ef|grep -v grep|grep -i XboxMediaCenter
then
# If it's still around, kill it -9
killall -9 XboxMediaCenter
echo `date` "Killed XBMC! (hard)" >> $LOG
fi
fi

echo date "Starting XBMC" >> $LOG
export DISPLAY=:0.0
cd $XBMC_HOME
./XboxMediaCenter -fs &
XBMC machine: ABIT AN-M2HD with nVidia 7050 onboard (Ubuntu Hardy + latest nVidia driver), AMD Athlon BE-2350, Microsoft MCE IR Remote, Logitech PS3 USB keyboard, 33w idle, 53w max, 720p plasma over HDMI
Reply
#5
If you have the binary nVidia driver installed, as you need to for XBMC to work, suspend probably does not work for your machine. Here is how to get suspend working. These instructions are from here, but cleaned up a bit. They worked for me. Resume takes about 8 seconds.

1. Add an "Option "NvAGP" "1" in /etc/X11/xorg.conf

Edit existing "Device" section to add Option "NvAGP" "1":

Section "Device"
Identifier ...
Driver "nvidia"
Boardname "nv"
...
Option "NvAGP" "1"
EndSection


2. Disable the agpgart module in /etc/modprobe.d/blacklist

Add the following lines to your /etc/modprobe.d/blacklist file:

blacklist intel_agp
blacklist agpgart


3. Two edits to /etc/default/acpi-support

3a. Disable warm-booting the video hardware

Edit /etc/default/acpi-support to set POST_VIDEO=false

3b. Disable SAVE_VBE_STATE option

Edit /etc/default/acpi-support to set SAVE_VBE_STATE=false

4. Disable compiz VBLANK sync

Run this from the command line:

gconftool --set /apps/compiz/general/screen0/options/sync_to_vblank 0 --type bool
XBMC machine: ABIT AN-M2HD with nVidia 7050 onboard (Ubuntu Hardy + latest nVidia driver), AMD Athlon BE-2350, Microsoft MCE IR Remote, Logitech PS3 USB keyboard, 33w idle, 53w max, 720p plasma over HDMI
Reply
#6
If you're having problems with the SVN releases, follow this procedure before posting to the forums.

1) Back up your Userdata directory just in case.
Code:
cd ~
tar zcvf home_xbmc.100208.tgz .xbmc

2) Delete the entire SVN code tree and uninstall XBMC
Code:
cd ~/XBMC
make uninstall
cd ~
rm -Rf ~/XBMC

3) Re-download the entire SVN code tree from SVN.
Code:
cd ~
svn checkout https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/linuxport/XBMC

4) Check the README.linux and copy/paste the entire apt-get line to ensure that you have the required dependencies. Note that this line does change as new dependencies are added for various features.

5) Rebuild and reinstall XBMC.
Code:
cd ~/XBMC
./configure --disable-debug
make -j2
make install

If you want to post a debug log, do not configure with the --disable-debug flag. If you don't have a multicore CPU, don't build with the -j2 flag.
Reply
#7
1) Compile XBMC with debugging enabled.

2) Start it up in windowed mode under the debugger via

Code:
export XBMC_PLATFORM_MODE=1
gdb /usr/local/share/xbmc/xbmc.bin

3) At the prompt startup XBMC

Code:
(gdb) run

3) At this point XBMC will start up. Then make the program crash, recreating your issue.

4) Once it crashes, you'll end up back at the (gdb) prompt. Type

Code:
(gdb) backtrace

5) Copy all the text from your console from when you started gdb, including the backtrace, and post it at

http://pastebin.com/

6) Post the pastebin link to the forums.
Reply
#8
Lightbulb 
Gutsy PPA packages available .

Just add the gutsy team-xbmc PPA to your repositories and install xbmc

Use the steps described in the Ubuntu documentation with the following repositories . You might not need to add the deb-src one .


Code:
deb [url]http://ppa.launchpad.net/team-xbmc/ubuntu[/url] gutsy main
deb-src [url]http://ppa.launchpad.net/team-xbmc/ubuntu[/url] gutsy main
See : https://edge.launchpad.net/~team-xbmc/+archive

The code level is SVN rev 12195 , compile with --nodebug and there isn't MythTV support (the option wasn't add on compile time and isn't there by default).

The label is 2.1a1-gutsy2

If you want me to update the package with some other compile options please request it. The label will be changed to 2.1a1-gutsy3.

If you want the build from another SVN revision then the label should be changed to 2.1XY-gutsyZ where :
  • X => a (for alpha) or b (for beta) ...
  • Y => version number
  • Z => version number for debian packaging stabilization and issues fixing.
Please have a look at the FAQ I have created in Launchpad on the process how to request for a package :
https://answers.edge.launchpad.net/xbmc/+faq/80

If you have some comments and modification, please let me know .

Next step is to ask and create the package for gutsy.
If it's done right now, I'll update and upload the source to the PPA.
Reply
#9
Hi!

Tried this under Hardy, but could not find XBMC in the packet manager.

Is this still valid, or is there a "trick" to it?

/n00b...
Reply
#10
This was only for Gusty. Hardy is not officially supported yet.

But I have created a package for Hardy (which is highly instable) .
For this, use the same trick with the information at:

https://edge.launchpad.net/~team-xbmc-hardy/+archive/
Reply
#11
Thanks for the response!

Still cannot see xbmc in adept....

Have added repositiories before (i.e. for Skype), but cannot get this one to work..
Reply
#12
odinb Wrote:Hi!

Tried this under Hardy, but could not find XBMC in the packet manager.

Is this still valid, or is there a "trick" to it?

/n00b...

I've had XBMC running in Hardy for about a week - seems very stable. I'm watching HD and SD content, browsing for share on the LAN etc. It's all good.

Just build from source using the tips in README.LINUX
Reply
#13
I couldn't get it through synaptic when i tried about a week ago. like MrDohnuts I built it from source and it is very stable.

the only problem I had was that setting resoultion to match desktop wouldn't save on reboot which was fived by going into userdata (in the BUILD folder of course) and deleting guisettings.xml. Next time you set the resoultion settings the file will be regenerated and the settings will stick. Make sure you set it from Appearance in settings and not Video in settings. (thanks Jezz_X for this tip).

Building from source is actually easier than it sounds too. (for beginners like me)

Code:
# sudo apt-get install subversion
# cd $HOME
# svn checkout https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/linuxport/XBMC

Install Ubuntu 8.04 Hardy Heron required dependencies forund in README.linux which subversion just downloaded or can be found HERE.
Just run this to install.
Code:
#sudo apt-get install make g++-4.1 gcc-4.1 libsdl1.2-dev libsdl-image1.2-dev libsdl-gfx1.2-dev libsdl-mixer1.2-dev libsdl-sound1.2-dev libsdl-stretch-dev libfribidi0 libfribidi-dev liblzo1 liblzo-dev libfreetype6 libfreetype6-dev libsqlite3-0 libsqlite3-dev libogg-dev libasound2-dev python2.4-dev python2.4 python-sqlite libglew1.5 libglew1.5-dev libcurl3-dev g++ gawk x11proto-xinerama-dev libxinerama-dev libxrandr-dev libxrender-dev libmms-dev pmount libmad0-dev libtre-dev libogg-dev libvorbis-dev libmysqlclient15-dev libhal1 libhal-dev libhal-storage1 libhal-storage-dev libpcre3-dev subversion libjasper1

next just BUILD by running these codes.
Code:
# cd $HOME
# cd XBMC
# svn update
# ./build.sh

finally to launch xbmc just make sure you're in the right directory and launch app.
Code:
# cd BUILD
# ./XboxMediaCenter -q

press they "/" key to view in full screen. Set resolution in appearance settings to match desktop for full screen.

I say xbmc is ready for prime time and all we need is a self install 700mb.iso that uses whatever method ubuntu uses to detect and install drivers but instead without gnome desktop and other uneccessary bloat but just gdm for auto launch. I'm not a dev and wouldn't know how to do this but just my two cents.

-As usual good job to the xbmc-linux community for building the best media center out there hands down.
Reply
#14
sorry i think it's "\" key to toggle full screen off and on.

could not find an edit button.
Reply
#15
Thanks guys!

Will try this later this weekend.

Going to a concert now....(Roger Waters)
Reply

Logout Mark Read Team Forum Stats Members Help
XBMC for Linux - Tips and Tricks2