Running cec-client with Raspberry PI on Debian or Ubuntu 64-bit

Using cec-client with a raspberry pi on debian or ubuntu does not work out of the box, as the cec-client in the debian and ubuntu repositories has not been compiled with support for the propriary raspberry libraries. In addition, these libraries are 32-bit only. This is a guide in how to get this working.

First you need to set up a 32-bit chroot environment. Install debootstrap and then run

debootstrap --variant=buildd --arch=armhf bullseye /opt/cec-client/

You will then need to download the raspberry pi libraries. Unpack /opt/vc from the tarball into /opt/cec-client (replace url with newer version if needed):

cd /tmp
curl -L | tar zxf -
cp -r firmware*/opt/ /opt/cec-client/

Add the raspberry pi lib to ldconfig by running

echo "/opt/vc/lib" > /opt/cec-client/etc/

You can now compile libcec and cec-utils:

chroot /opt/cec-client
apt-get update
apt-get install cmake libudev-dev libxrandr-dev python3-dev swig git 
cd /tmp/ 
git clone
mkdir platform/build
cd platform/build
cmake .. 
make install
cd /tmp/
git clone
mkdir libcec/build
cd libcec/build
cmake -DRPI_INCLUDE_DIR=/opt/vc/include -DRPI_LIB_DIR=/opt/vc/lib ..
make -j4 
make install
cd /tmp/
mkdir libcec/src/cec-client/build/
cd libcec/src/cec-client/build/
make install

In order to run cec-client inside the chroot, you will also need access to devices. You can do this by mounting this up before running chroot, but an easier and better way is to use systemd. Many of the examples you will find of how to use cec-client adds the -s flag to run a single command, but without this, cec-client runs until told to quit and listens on commands on stdin. We will use this and let systemd set up a fifo for commands for us. Create the socket and service files:

Description=CEC client socket


Description=CEC client

ExecStart=/usr/local/bin/cec-client -d 1
ExecStop=/bin/bash -c "echo q > /run/cec.fifo"


Then reload systemd, enable and start:

systemctl daemon-reload
systemctl enable cec-client.socket
systemctl start cec-client.socket

You can now send cec-client commands by writing to /run/cec.fifo, for instance to turn on the tv with address run

echo 'on' > /run/cec.fifo

CC BY-NC-SA 4.0 This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

4 thoughts on “Running cec-client with Raspberry PI on Debian or Ubuntu 64-bit”

  1. Hi,

    I’m a bit of a noob around linux/pi so apologies if this is a silly question, but what is the line
    “cmake .. make”
    supposed to do?

    I’m following along this install to get hdmi cec on my Pi 400 with Debian 11 installed and getting tripped up there.


    1. Hi, not a silly question at all. It was a typo, it should have been a new line there, so the command are “cmake ..” and then “make”. I’ve updated it now, hope that helps you to get it build

  2. Hello there,

    i just wanted to get this going on my RasPi but i guess there is a mistake in your guide (or i do not get it since i am pretty much of a unix noob ;-)).

    I ran every step of the guide but if i want to execute an cec command using the fifo file it seems like nothing is happening. For example if i want to see if the cec client works by checking which devices are connected i do not get any output. I am executing “echo ‘cec-client -l’ > /run/cec.fifo” i a shell on my RasPi (not in the chroot environment).

    I wanted to troubleshoot that myself first and found that “cec-client” does not exist in “/usr/local/bin/” as specified as “ExecStart=” in “/etc/systemd/system/cec-client.service”. Is that meant to be that way or could that be the issue?

    Thanks and regards,

    1. Hi Jakob

      The guide installs cec-client with 32-bit dependencies in “/opt/cec-client”, so the path to cec-client would be “/opt/cec-client/user/local/bin/cec-client”. In order to test it manually, you can run “chroot /opt/cec-client /usr/local/bin/cec-client -l”.
      You should get the output from cec-client through journald, ie, run “journalctl -u cec-client.service”

      Hope this help


Leave a Reply

Your email address will not be published. Required fields are marked *