Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4491

Advanced users • cec-client, cec-ctl on Bullseye

$
0
0
I just rebuilt a DakBoard Pi and there have been some changes in the past 2 years regarding cec control. My last DakBoard was on Buster and I was able to use cec-client commands to control the TV from cronjobs. None of those cec commands are working from terminal on the new Bullseye build. Research indicates that Pi has moved into using cec-ctl commands. I did get some working, but not reliably. It appears that the active device can control the tv fine, but if I make my DirecTV receiver the active, then the Pi can no longer control the TV's power. Not sure how to override that.

I did some poking around in the DakBoard's files and found two bash scripts that indeed use cec-client. I'd like to tap into those commands and see if there is something I need to revisit.

First one I found was called "rpi-hdmi.sh" and it has alot of what I was using in the last build. Some of those commands look very familar.

Code:

 #!/bin/sh#Enable and disable TV/HDMIhdmi_status (){                export DISPLAY=:0                xrandr --current | grep "HDMI-1 connected" >/dev/null}cec_status (){            echo 'pow 0' | cec-client -s -d 1 | grep "power status: standby" >/dev/null}case $1 in            on)                        echo 'on 0' | cec-client -s -d 1 | grep "opening a connection to the CEC adapter..." >/dev/null &                        echo 'as' | cec-client -s -d 1 >/dev/null &                        /home/dakboard/startup/init-display.sh > /dev/null 2>&1 &                        /home/dakboard/startup/init-audio.sh > /dev/null 2>&1 &                        echo "Display and HDMI have been turned on by user."                        DISPLAY=:0 /home/dakboard/startup/init-touch.php >/dev/null            ;;            off)                        echo 'standby 0' | cec-client -s -d 1 | grep "opening a connection to the CEC adapter..." >/dev/null                        export DISPLAY=:0                        xrandr --output HDMI-1 --off > /dev/null 2>&1            xrandr --output HDMI-2 --off > /dev/null 2>&1                        echo "Display and HDMI have been turned off by user."            ;;            status)if hdmi_statusthenecho "The HDMI port is OFF"elseecho "The HDMI port is ON"fiif cec_statusthenecho "The display is turned OFF"elseecho "The display is turned ON"fi            ;;*)echo "Usage: $0 on|off|status" >&2exit 2            ;;esacexit 0
Another one I found is called "opi-hdmi.sh" and also has some familiar elements.

Code:

#!/bin/sh#Enable and disable TV/HDMIhdmi_status (){            export DISPLAY=:0xrandr --current | grep "HDMI-1 connected" >/dev/null}cec_status (){            echo 'pow 0' | cec-client -s -d 1 | grep "power status: standby" >/dev/null}case $1 in            on)                        echo 'on 0' | cec-client -s -d 1 | grep "opening a connection to the CEC adapter..." >/dev/null                        echo 'as' | cec-client -s -d 1 >/dev/null                        /home/dakboard/startup/init-display.sh                        /home/dakboard/startup/init-audio.sh                        echo "Display and HDMI have been turned on by user."                        DISPLAY=:0 /home/dakboard/startup/init-touch.php >/dev/null            ;;            off)                        echo 'standby 0' | cec-client -s -d 1 | grep "opening a connection to the CEC adapter..." >/dev/null                        export DISPLAY=:0xrandr --output HDMI-1 --off                        echo "Display and HDMI have been turned off by user."            ;;            status)if hdmi_statusthenecho "The HDMI port is OFF"elseecho "The HDMI port is ON"fiif cec_statusthenecho "The display is turned OFF"elseecho "The display is turned ON"fi            ;;*)echo "Usage: $0 on|off|status" >&2exit 2            ;;esacexit 0
The only difference between these is line 28.

Can there be something learned from this to help me get the cec-client commands working in Bullseye? Do I need to run my old cec-client commands from within a specific location to make them work?

Statistics: Posted by duckredbeard — Thu Nov 14, 2024 12:11 am — Replies 0 — Views 37



Viewing all articles
Browse latest Browse all 4491

Trending Articles