CEC and run custom command

How if possible to run custom command when TV is going on/standby/completely off?

These signals seem to be flying over CEC and Kodi is able to catch it and go into standby and wake up. This is fine for most people.

What is really needed is capability to run custom command on any of the three events on/standby/completely off.

Why?
System needs to run 24h/7 as runs some very lightweight docker containers and need to start kodi process only when Tv is on.
Why? Well Kodi is the most CPU hungry one, generates heat and consumes power - maybe not a lot but still something what can be skipped.

Did a lot of reading and didn’t find a way to debug CEC messages and have no idea how to catch it, tried with cec-client and whilst seems like I can push requested onto the wire:

$ echo 'standby 0' | cec-client

I don’t see that much and have didn’t find utility to take action upon a message on CEC.

Side observation is that anytime TV is requested to go into Standby either via Remote or CEC message, it turns on back after couple of seconds.

boot.ini is left at defaults:
setenv hdmi_cec "1"

The only so so detail found in journalctl is that when input is set to the one CE is connected it logs:
kernel: hdmitx: system: plugin

when set to other of physically TV is off it shows:

kernel: hdmitx: system: plugout
kernel: hdmitx: system: update physcial size: 16 9

It’s probably not the best idea to setup watcher on journalctl, hence trying to find more optimal way. I can’t believe I’m the first one looking for it, but couldn’t find any solution so far.

Another workaround is to have a cronjob */5 or */10 to check /sys/class/display/vinfo for screen_real dimensions - yet that causes delay, i.e. in turning on Kodi.

Hardware is: N2
Software is CE 9.2.1

Thanks in advance.

1 Like