CEC HDMI Monitor (Check if Screen is On or Off + Turn On and Off Commands) - Android | Linux


CEC is already an old technology, I think we could explore it more in Xibo’s software.

Some simple commands could greatly improve project management using XIBO. I achieved some interesting results in 1h30 of work, and I would like to leave this suggestion for the Xibo team and the Community!

User Story

I spent the weekend testing an Android BOX that has the HDMI CEC protocol support.

I managed to turn my TV on and off with simple commands through the Xibo Android app by sending the commands below:

echo "0x40 0x04" > /sys/class/cec/cmd - turn on

echo "0x40 0x36" > /sys/class/cec/cmd - turn off

(I am aware that the commands vary depending on the TV/Screen model; I just used an example here.)

I used this website to better understand the commands: https://www.cec-o-matic.com/

During some research, I came across this very interesting topic: HDMI CEC ( Control HDMI attached TV/device ) - Request - Kodular Community

The topic is about monitoring whether the TV devices are on or not. As we know, one of the major pains of digital signage is knowing whether my content is being displayed or not because of a turned-off Screen.

I thought it would be a great native feature for Xibo Android and Linux. A monitoring system to identify whether the TVs are on or not.

I even managed to do this (in a very basic way) by analyzing the buffer of the “dump_reg” file in the CEC control folder for Android.

cat dump_reg | grep -q "RX buffer: 04" && echo "TV On" || echo "TV Off"

if it contains the segment “RX buffer: 04” the TV is on, if not, it’s off.

(TV On)

(TV Off)

I could use this output to send the status of the TV/Screen as well as the Xibo player to my CMS.

I believe that devices with CEC and ROOT access could send these commands and analyze the output without much problem. Besides, it would be a great feature idea for the Linux player in development.

The result in the CMS will be something like this:

(The image above is just a representation of what the final result would look like.)

Here’s my suggestion!


Hello Mr. Paulo,
Thank you for your information, this information is very useful. I hope this information can be applied to windows

Best regards,



Hi Ray!
Yes, that would be great… but:
In Windows i’ts way more complicated, since that Android and Linux can use the “cec-utils”/“cec-client” library to get the information about HDMI status.
As far as i know that it’s not possible in windows without using and external hardware device like “pulse-eight”.
So is way easier to get this function on Android an Linux Player, but who knows!



This is actually really really useful!
I tried to achieve the same thing, when I read that CEC is mostly an one way communication, i stopped researching.

Thank you for your time, i will try to implement this in our environment. Our junior developer is almost dreaming Xibo api, I will ask him to check this topic and see if he can get results. We have our own status page which checks and colors the line if a display is offline for more than 4 hours. This status page also contains quick command buttons to turn on/off displays. We don’t want our supportdesk clicking arround in the actual Xibo portal since you can break more than fix (without knowledge).



Here’s a command to send via XMR (to android’s that have HDMI CEC support) or by scheduled command that turn on the screen and change the input source to the correct HDMI:

echo "0x40 0x04" > /sys/class/cec/cmd; sleep 3; echo "0x4F 0x82 0x10 0x00" > /sys/class/cec/cmd 


echo "0x40 0x04" > /sys/class/cec/cmd; sleep 3; echo "0x4F 0x82 0x20 0x00" > /sys/class/cec/cmd 


echo "0x40 0x04" > /sys/class/cec/cmd; sleep 3; echo "0x4F 0x82 0x30 0x00" > /sys/class/cec/cmd 


i’ll try to create a command that do this dynamically and share with you to test.


Here it is: this command analyzes the “port_info” file, captures the physical_address (HDMI port) to which the Android device is connected, sends the command to turn on the screen, and then changes the HDMI input to the correct port:

addr=$(awk -F 'physical_address: ' '{print $2}' /sys/class/cec/port_info | cut -d ',' -f1) && echo "0x40 0x04" > /sys/class/cec/cmd && sleep 3 && echo "0x4F 0x82 ${addr:0:1}${addr:1:1} ${addr:2:1}${addr:3:1}" > /sys/class/cec/cmd

This one does the same thing but by analyzing the “physical_addr” file, however, I didn’t feel very secure about it.

addr=$(cat /sys/class/cec/physical_addr); echo "0x40 0x04" > /sys/class/cec/cmd; sleep 3; echo "0x4F 0x82 ${addr:0:1}${addr:1:1} ${addr:2:1}${addr:3:1}" > /sys/class/cec/cmd

to check if the screen is on or off we can use the command bellow:

echo 0x40 0x8F > /sys/class/cec/cmd

the result will be registred in the “dump_reg” file at the RX buffer line:

90 00 - Screen On

Anything different that - Screen Off

i created this command to read the file and output the screen status:

echo 0x40 0x8F > /sys/class/cec/cmd; cat dump_reg | grep -q "RX buffer: 04 90 00" && echo "TV On" || echo "TV Off"

The commands for Linux are different, but not by much. I think they are even less complicated.

Well, this is my contribution so far. Please test the commands on other TV devices with CEC if your Android has root and HDMI CEC (i tested on AOC TV’s but I think that it will work well in other devicec with HDMI CEC ).
I hope the information above can pave the way for the Xibo team to consider this functionality in the Android | Linux players.


Hello Mr. Paulo,
Thank You for your reply. You are absolutely right. In Windows, CEC is complicated. In Windows, it must use external hardware device like pulse eight. I’ve been looking for a way for CEC to work without external devices like pulse eight but I’m stuck. But the topic you conveyed is very useful for Linux users.

Best regards,



This is a great idea and is something we’ve been exploring recently as well (although you’ve got more commands working than we did!).

As a side note we’d also like to extend the information we present with EDID.

I’ve grabbed a link to your research and will add it to our blueprint.


I really like it.
Good work pitoco02.

It’s a great improvement idea.
Lots of customers ask me for a screen status.
I’ve been confronted a few times where screens don’t turn on with HDMI CEC commands, and this could be the solution to this problem, checking whether the screen is on, or sending an alert (email) if it isn’t.

You’ve made me want to look at this and implement it in conjunction with the Xibo API.

How did you access to Android commands?

1 Like

I’ve been exploring many Chinese forums for a few days haha :rofl:.
I’ve also been confronted by my users about the lack of this functionality, so I decided to devote some time to address this demand and share it with the Community.

This website shows all possible HDMI CEC commands; for Android, simply replace the separator “:” for “0x” as seen in the commands I sent.

The “cmd” executable in the “/sys/class/cec/” folder (becoming “/sys/class/cec/cmd”) waits for a hexadecimal command via “echo” with the syntax mentioned in the previous paragraph and sends the commands through the HDMI cable.

From my research, the CEC protocol codes are the same for all screens/ TV models that have CEC.
What may change is just the separator and the syntax depending on the operating system.

The commands I sent will work on any Android with ROOT and CEC, sending commands to any screen that has HDMI CEC (I’ve tested with AOC, Samsung, and LG, but I can almost guarantee it works with any other since the HDMI CEC protocol won’t change from TV to TV).

Commands can be sent via XMR to Androids, or scheduled commands through the “Schedule” menu without the need for third-party Apps, as long as both the Android and the TV/Screen have CEC."

The “turn on/off” feature can currently be implemented without any modifications to the Xibo software. However, I would really like to see the “Screen On/Off Monitor” function integrated natively into the Xibo apps for Android.

If you manage to implement this idea with the Xibo API, please share with us how you did it so that we can apply it to our CMS as well :slight_smile:

Thank you!