2007-12-22, 07:37
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:
=== 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.
=== 4
This script will start the IR daemons. Create it as "/home/youruser/scripts/startIRexec.sh":
=== 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)
/home/youruser/scripts/killXBMC.sh:
=== 7
Make the scripts executable.
=== 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!
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!