Why would you want to do this?
I use my RPi for XBMC and as a web server (yet to reinstall after switching to Raspbmc). I do not always want XBMC running, as I am not always home and also not always watching films! So in the interests of saving system resources I wanted to stop XBMC and shut off the HDMI to stop any TV interference. There are two commands to do this, but they are quite long and not easy to remember! I needed something to shorten this process. Preferably xbmc start/stop.
This is how I implemented it.
When you have SSH’ed into your Raspbmc box, we are going to add a custom command to the .bashrc file. This controlled the shell environment, and allows you to create custom commands to call from the command line.
Step 1: Edit ~/.bashrc file.
~$ sudo nano ~/.bashrc
when you are here, use ctrl+v to page down to the bottom of the file. (of course, you can use vi).
Add the following code to the bottom of the file:
if [ $* = "start" ] ; then
sudo initctl start xbmc
if [ $* = "stop" ] ; then
sudo initctl stop xbmc
press ctrl+o; ctrl+x to save and exit the file.
If you want to control HTML only, remove the BLUE lines from the above code and change the function name to hdmi.
Restart bash without restarting the session.
~$ source ~./bashrc
Type the following command to test it works:
~$ xbmc stop
You should now see XBMC shutdown and the TV / Monitor report no source input. However, notice you are still logged into the session and the Pi is still on.
To start xbmc and the hdmi out use
xbmc start, to stop the service use
You can also hack a function to turn on the HDMI port if you want, just omit the XBMC stuff, call it hdmi () and use on/off!
Leave a comment if you have tried this and it worked, or AMA. I couldn’t find this anywhere else on the net to I thought I would post it.