Hey guys,
I am pretty new to scripting on a Linux based system so my thoughts are kind of blank about any command I have to work with. I already tried to find something similar using the forums search and google but that was not successful. Maybe you guys can help me.
I have a Raspberry Pie 3 and it is running Kodi / LibreELEC. The device is connected to my TV via HDMI.
There are two use cases that I would like to make easily accessible:
1. Watching a movie / TV Show. In this case I want the Pi to use HDMI as audio outport so I hear the sound from the 5.1 system (which is connected to the TV).
2. Listening to music. In that case I want to connect a Bluetooth speaker to the Pi and make it use Blutetooth as audio outport.
I know I can do this in the settings, but it is a little inconvenient. Also, some sort of a one-click-solution would even make it usable for my wife and my son
That's why I thought of a script.
I want a script to be started when I hit a specific key on the remote control (CEC). Therefore I created a file named keymap.xml in /storage/.kodi/userdata/keymaps/. It contains the following code:
<keymap>
<global>
<remote>
<!-- 207 = "0" @ remote control -->
<key id="207">RunScript("/storage/scripts/AudioOut_trigger.sh")</key>
</remote>
</global>
</keymap>
This should be working I guess...
The *.sh file doesn't contain anything yet. As I wrote above I have no specific idea about which commands to use. I am not even sure if it makes the most sense to write a shell script or to better do it with python or something. It's probably a matter of taste or belief.
What I know is what the script should do (in pseudo code):
if (audio output != Bluetooth Audio)
Message("Turn on Bluetooth speaker")
Wait for user to press OK
bluetoothctl
connect 88:C6:26:50:63:B6
wait until positive response (max. 3 sec.)
try to connect two more times in case of negative response
quit #quit bluetoothctl
if (connection established)
popup("speaker connected")
set audio output = Bluetooth Audio
popup("audio output is Bluetooth Audio")
else
popup("could not connect to speaker")
set audio output = HDMI
popup("audio output is HDMI")
else
set audio output = HDMI
popup("audio output is HDMI")
Display More
Can you guys help me to realize that idea?
Thank you all in advance!