I power my RPi from the TV USB (yes, I know some people say that this will not be enough power but it works really well for me).
However, if the TV source is switched to watch some live TV and then, later, the TV is (soft) switched off it would be good if RPi could be set to notice that an initiate an orderly shutdown to reduce the risk of a corrupt file system.
On my TV the USB power is kept up for about 2 minutes after the TV is turned off - so this could work well.
Clearly I am looking for this to happen when the TV is switched off - not when the RPi is no longer the active display.
Is there any HDMI CEC chatter between the TV and it's connected devices that could be used as the trigger?