Got it!
Basically, you have to write a script to launch/activate xbmc, then bind that script to a key/action in openbox's rc.xml.
(edit- Ok, apparently I never read the thread title. I thought this was about launching xbmc, not launching something FROM xbmc. Pretty much the same solution though.)
The script
This is a little complicated because XBMCbuntu/Linux allows you to run multiple instances of XBMC. In other words, if XBMC is already open and you launch it again, you end up with two copies of XBMC open at the same time. Not good. (Some people want multiple instances for multiple screens, but that's not us).
In Windows, if you try to open XBMC again it just sets focus to the instance that's already open. If XBMCbuntu worked this way, we could just put "xbmc" into the openbox rc.xml and be done. Unfortunately, we'll have to put in some extra work to emulate the Windows XBMC behavior. Luckily, I found a script to accomplish this.
First of all, we need a little help. I read some complicated stuff about how shell scripts basically don't have access to program windows, so we need to install wmctrl to handle this for us.
Code:
sudo apt-get install wmctrl
Next, I created a script called startxbmc.sh in my home directory.
And here's what I put inside it:
Code:
#!/bin/bash
ISXBMCUP=`ps -e | grep xbmc.bin | grep -v grep | wc -l` # Check if XBMC already running (don't want to start another session).
if [ $ISXBMCUP -eq 0 ]; then # If XBMC isn't running, then OK to start it.
xbmc &
else
wmctrl -a xbmc
fi
exit
Ctrl+O to save. Enter to confirm. Ctrl+X to exit.
Then you have to make the script executable.
Code:
chmod +x ~/startxbmc.sh
Now you can test it. Run this with XBMC closed, and it should open. Run this with XBMC open, and it should get focus.
The keybind/action
Once you have a working script, you can assign it to the XF86HomePage key (or whatever keyboard shortcut you want).
Open rc.xml in your favorite editor.
Code:
nano ~/.config/openbox/xbmcbuntu-rc.xml
Look for the
<keyboard> section (you'll gave to scroll down a while), then keep going down until you find a bunch of
<keybind key="XF86blablabla. If you don't find any XF86___ keybindings by the time you get to the bottom of the </keyboard>, then you can just add the code inside the keyboard section
If you find
<keybind key="XF86HomePage"> you can edit it, but I had to add mine from scratch. It looks like this:
Code:
<keybind key="XF86HomePage">
<action name="Execute">
<command>~/startxbmc.sh</command>
</action>
</keybind>
Save and close.
This assigns the script we wrote to the HomePage key (which is the PS key on my PS3 remote)!
To make the changes take effect, you can
Code:
openbox --reconfigure
or
Done! (let me know if there are any mistakes in this "guide")
References:
http://forum.xbmc.org/showthread.php?tid=149206
http://superuser.com/questions/142945/ba...fic-window
https://bbs.archlinux.org/viewtopic.php?id=93126
http://openbox.org/wiki/Help:Bindings#Key_combination
Quick note:
I imagine this should work for any keyboard with a Home/Browser key. My PS3 remote has the PS key assigned to the Home key in /etc/bluetooth/input.conf (0x43 = KEY_HOMEPAGE). If your PS3 remote is set up using LIRC or something weird, you might have to figure out how to make the PS key act like a keyboard's homepage key for this guide to work.