Is it possible to use a keyboard shortcut for that setting?
Or at least a command to use at the command line?
Hi,
This is exposed as a Kodi setting so it’s not trivial to toggle it.
Can I ask why you need to regularly cycle between muting HDMI? Are you using an optical cable?
Yes, I‘m using an optical cable.
I‘ve already asked in the Kodi forum where they asked me to ask here again because they don‘t know that setting…
“That’s not a standard Kodi setting so must have been added by OSMC so you’ll need to ask there.”
“HDMI mute - beneficial for users with old AVR’s that need SPDIF only audio
thx @samnazarko”
Are there 2 different Sam Nazarkos?
It looks like @wrxtasy added that commit to his project and the ‘thx’ is to recognise that the change came from us (OSMC).
If you’re using an opticial cable; you should only need to set this setting (once) to enable it.
Alternatively, if you have a remote key free, you could bind it to run a Python script which disables the HDMI audio via sysfs (as that’s all our setting does).
I want to switch between audio over my TV and my stereo, that’s why I asked for a toggle - please tell me how to add a python script to a key.
Which remote do you have?
An HP MCSE Remote and a Logitech K400 keyboard.
You can set up a custom remote XML to do this
Could you please explain how to do that?
Okay, but what’s the command I have to use?
Please consider that I’m not a developer…
You will need to write a script and define a keymap to do this. That’s unavoidable unfortunately
Sam
Okay, got it… you don‘t want to help.
I’m more than happy to help you; but you haven’t even told us which key you wish to remap.
You will need to edit some files on the system to add the functionality that you have requested.
Sam
It‘s less important which key to remap, but let‘s say I want to remap the „h“ key.
I‘m also aware that I have to edit some files, but I still don‘t know which command(s) have to be put into the script.
Ok,
HDMI audio can be turned off/on with:
echo audio_off > /sys/class/amhdmitx/amhdmitx0/config
echo audio_on > /sys/class/amhdmitx/amhdmitx0/config
respectively.
So you would need a Python script to write this sysfs value.
Sam
Okay, it works when I use 2 key maps, “h” for off, “i” for on for example
Now I tried to toggle the status with the following script:
import subprocess
file = open("/home/osmc/scripts/HDMI_status.txt", "w+")
if file.read() == "off":
subprocess.call(["/home/osmc/scripts/HDMI_on.sh"])
file.write("on\n")
else:
subprocess.call(["/home/osmc/scripts/HDMI_off.sh"])
file.write("off\n")
file.close()
If audio is on pressing the toggle key sets the output off, but when I press the toggle key again nothing happens.
Check the value you are getting from file.read(). My guess is that it’s reading the newline, so the proper test would be:
if file.read() == "off\n":
Or, instead of saving your status file with the newline just do:
file.write("on")
Got it working now:
import subprocess
file = open("/home/osmc/scripts/HDMI_status.txt", "r")
inhalt = file.read()
file.close()
file = open("/home/osmc/scripts/HDMI_status.txt", "w")
print(inhalt)
if "off" in inhalt:
subprocess.call(["/home/osmc/scripts/HDMI_on.sh"])
file.write("on")
else:
subprocess.call(["/home/osmc/scripts/HDMI_off.sh"])
file.write("off")
file.close()