Toggle for „Mute HDMI Audio Output“

Is it possible to use a keyboard shortcut for that setting?
Or at least a command to use at the command line?


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?

See Custom Script on custom remote key[Remote app]

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


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.


1 Like

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.


HDMI audio can be turned off/on with:

echo audio_off > /sys/class/amhdmitx/amhdmitx0/config
echo audio_on > /sys/class/amhdmitx/amhdmitx0/config


So you would need a Python script to write this sysfs value.


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 == "off":["/home/osmc/scripts/"])



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 My guess is that it’s reading the newline, so the proper test would be:

if == "off\n":

Or, instead of saving your status file with the newline just do:


Got it working now:

import subprocess

file = open("/home/osmc/scripts/HDMI_status.txt", "r")
inhalt =

file = open("/home/osmc/scripts/HDMI_status.txt", "w")


if "off" in inhalt:["/home/osmc/scripts/"])


1 Like