Linux Run A Shell Script With A Keyboard Shortcut in XBMC
#1
How do you run a shell script with a keyboard shortcut? Will one of the Built-In Functions do this?

I have a script that I use to toggle sound output between HDMI and my G930 headset. The keyboard shortcuts work in Ubuntu 12.04 and in Steam, but I can't figure out how to set the keyboard shortcut to work in XBMC.

My script is located in /usr/local/bin/sound-toggle.sh

I'm running Frodo and I can trigger the .sh with Advanced Launcher, but a keyboard shortcut would be really helpful.
Reply
#2
Have you try to create a favourite of your sound-toggle.sh script from Advanced Launcher, then use this favourite as an action into your keymap.xml file? Somthing like this :

Code:
<your_key>XBMC.RunScript(&quot;plugin://plugin.program.advanced.launcher/?cat_id/launcher_id&quot;)</your_key>

Where : your_key is the key you want to assign, cat_id is the ID of the category of your launcher and launcher_id is the ID of your sound-toggle.sh script launcher. cat_id and launcher_id values can be found into the xbmc/userdata/favourites.xml file.
Reply
#3
Here's a couple I have mapped in the keyboard.xml. I actually have them set to keys on my Harmony remote, but it works as a keyboard using a Flirc. Anyway, I have the "b" keyboard key mapped to a script.

<a>EjectTray()</a>
<b>System.Exec(/home/xbmc/Scripts/restart-xbmc.sh)</b>
Reply
#4
I first tried to edit the keyboard.xml file from github, which I placed in ~/.xbmc/userdata/keymaps/. When that didn't work, I removed all the other shortcuts except for my custom commands. That still didn't work.

I tried both of the following shortcuts (with various keys for "your_key"):
Code:
<your_key>XBMC.RunScript(&quot;plugin://plugin.program.advanced.launcher/?default/e82a6c6940ce3a5aca09f9b5dc92bfd3&quot;)</your_key>
<your_key>System.Exec(/home/sound-output-device-switch.sh)</your_key>

The XBMC.RunScript command was unresponsive, and the System.Exec command caused XBMC to exit full screen and minimize (and the script didn't run). Any help is much appreciated.
Reply
#5
Maybe just try just :

Code:
<your_key>RunScript(&quot;plugin://plugin.program.advanced.launcher/?default/e82a6c6940ce3a5aca09f9b5dc92bfd3&quot;)</your_key>

Or you can also try :

Code:
<your_key>ActivateWindow(10001,&quot;plugin://plugin.program.advanced.launcher/?default/e82a6c6940ce3a5aca09f9b5dc92bfd3&quot;,return)</your_key>

or

Code:
<your_key>PlayMedia(&quot;plugin://plugin.program.advanced.launcher/?default/e82a6c6940ce3a5aca09f9b5dc92bfd3&quot;)</your_key>
Reply
#6
The PlayMedia command worked! I can now switch between my headphones and tv speakers using either a button on my wireless G930 headset or with my keyboard.

Thank you so much. Please have a drink on me. Sending a donation Smile
Reply
#7
Thanks for the donation.
Reply

Logout Mark Read Team Forum Stats Members Help
Run A Shell Script With A Keyboard Shortcut in XBMC0