I wanted to control the my television and blu ray player/receiver from my pi, so i installed the client on my raspbian pi installation.

Everytime cec_client start it's does some initializing, so i wanted to run is as some kind of daemon, i thought about a fire options, like maybe some expect kind of script without daemoniziing or a python with python expect to run it and control it, with mayne a socket.

I decided to use screen to run the cec_client and control the screen from bash scripts

screen -S cec_client -d -m /usr/bin/cec-client

After that we can find out that the last output is by running

screen -S cec_client -p0 -X hardcopy /tmp/.output.txt; cat /tmp/.output.txt

TRAFFIC: [          321646]     << 10:90:00
DEBUG:   [          321646]     >> TV (0) -> Recorder 1 (1): give device power s
tatus (8F)
TRAFFIC: [          381647]     >> 01:8f
DEBUG:   [          381647]     << Recorder 1 (1) -> TV (0): on
TRAFFIC: [          381647]     << 10:90:00
DEBUG:   [          381647]     >> TV (0) -> Recorder 1 (1): give device power s
tatus (8F)

You can create a little script to control the cec_client, just like typing in the shell, my scripts looks like


# from: www.zorrro-online.nl  example code
# example set source hdmi 1 on blueray/dolby receiver
# cec-send-command.sh "tx 1F:82:31:00"

# example set source hdmi 2 on blueray/dolby receiver
# cec-send-command.sh "tx 1F:82:32:00"

# cec-send-command.sh "on 5"          # blueray/dolby receiver on
# cec-send-command.sh "standby 5"     # blueray/dolby receiver off

screen -S cec_client -X stuff "$1\015"