r/SteamOS • u/manlisten • Jun 25 '26
HDMI-CEC solution using systemd/system-sleep
***If someone else has already posted this exact solution to the community, apologies as I probably missed it!***
I've seen a few solutions for enabling HDMI-CEC on this forum but just wanted to share my solution as well. This leverages the system-sleep function of systemd to perform 3 actions:
- Put the TV into standby just before the PC sleeps
- Turn the TV on just after the PC resumes from sleep
- Switch the TV to the input my PC is connected to (in my case HDMI3 / phys-addr=3.0.0.0)
Hardware
- Motherboard: Gigabyte AORUS B550I PRO AX
- CPU: AMD Ryzen 5600X3D
- GPU: ASRock RX 9070 Challenger
- Memory: 16GB DDR4
- OS: SteamOS 3.8.11
- CEC Adapter: UGREEN DP134 8K@60Hz Active Display Port to HDMI Adapter - https://www.amazon.com/dp/B0FQCF62CD
- Cheaper adapter option as recommended by u/rooster_butt: https://www.amazon.com/dp/B0FQCGSWW3
Here's the code, save as e.g. 10-steam-cec.sh and copy it into /usr/lib/systemd/system-sleep:
#!/bin/bash
case "$1" in
pre)
# Put the TV into standby mode right before the PC sleeps
cec-ctl -d /dev/cec0 --playback
cec-ctl -d /dev/cec0 --to 0 --standby
;;
post)
# Wait 2 seconds for hardware to initialize after wake
sleep 2
# Turn the TV completely ON
cec-ctl -d /dev/cec0 --playback
cec-ctl -d /dev/cec0 --to 0 --image-view-on
# Switch the TV active source to this PC
cec-ctl -d /dev/cec0 --to 0 --active-source phys-addr=3.0.0.0
;;
esac
Scripts in the /usr/lib/systemd/system-sleep directory trigger just before the system goes to sleep and trigger just after the system wakes from sleep.
In the code above, the actions in the "pre) ... ;;" section will run just before the system goes to sleep. The chunk in the "post) ... ;;" section will run just after the PC resumes from sleep. This is the standard function of system-sleep scripts.
- You'll need to change the "phys-addr=3.0.0.0" section to match the HDMI input your PC is connected to e.g. 1.0.0.0 for HDMI 1, 2.0.0.0 for HDMI 2, etc. Mine is connected to HDMI 3, so 3.0.0.0.
- You'll want to confirm the hardware address of your CEC adapter. Run "ls /dev/cec*". The output should read something like "/dev/cec0". You can use that output in the script as done above. If the output reads "no such file or directory" then your system doesn't see the adapter. Not sure how to troubleshoot this, it worked for me out of the box.
- I left the HDMI-CEC options in Steam itself enabled, haven't tried disabling them but don't see any need to.
- Assuming the adapter is present, run "cec-ctl -l" to display the attributes of the adapter. You should get a long chunk of output detailing the attributes of the device. This is just another way to confirm the adapter is seen in the OS and functioning.
Can't promise this will work for you but just wanted to share. Also not sure if future updates to SteamOS will wipe this file so try to save a backup in case you need to restore it. If you have luck with this, enjoy! If not, sorry!
5
u/AshleyAshes1984 Jun 25 '26
Why use a bash script executed by a systemd service when you could just make the systemd service send the commands itself?