Detecting if HDMI input is currently the TV's

2019-07-12 03:01发布

问题:

I am using a RPi connected through HDMI to a Samsung TV. I am attempting to trigger RPi processes so that they are only active when the HDMI output is being used by the TV. Effectively, I would like to start the process when the correct HDMI input is selected from the TV and terminate it when another TV source is selected.

I have tried to use tvservice –s for that end, but the command’s output does not change depending on whether the TV is configured to use the RPi’s HDMI or any other source.

Therefore, I welcome suggestions on what other mechanisms could be used (e.g. low-level drivers, libCEC, xrandr) to determine if the TV is currently using the RPI’s HDMI.

Thanks!

回答1:

HDMI sink devices (like TVs) no longer break the HDMI “handshake” when switching sources. When HDMI was young, switching sources would take 3-6 seconds... generally with a black screen during the interim. TV consumers found this unacceptable, so manufacturers created inputs which were “always on.” This makes the connection appear to remain on even when switched.



回答2:

You may try "tvservice --name" I have tried without connecting display it replied with "[E] No device present" Maybe it replies with Name of Tv when connected.