Kyle Gospodnetich 1761a1739b
feat: Add CEC control (#412)
* feat: Add CEC control (Default enabled only on deck/ally/framegame builds, edit /etc/default/cec-control to change behavior)
Original source is https://github.com/ChimeraOS/chimeraos/pull/428
Big thanks to BoukeHaarsma23

* chore: Fix missing default for sleep standby
2023-10-06 16:55:13 -07:00

24 lines
770 B
Bash
Executable File

#!/bin/bash
ACTION="$1"
source /etc/default/cec-control
# OVERRIDE WITH DEFAULTS IF NOT SET
CEC_TVID=${CEC_TVID:-0}
CEC_WAKE=${CEC_WAKE:-true}
CEC_SETSOURCE=${CEC_SETSOURCE:-true}
CEC_ONPOWEROFF_STANDBY=${CEC_ONPOWEROFF_STANDBY:-true}
CEC_ONSLEEP_STANDBY=${CEC_ONSLEEP_STANDBY:-false}
# Run specified actions
if [ "${ACTION}" = "onboot" ] && [ "$CEC_WAKE" = true ]; then
echo "on $CEC_TVID" | cec-client -s -d 1
if [ "CEC_SETSOURCE" = true ]; then
echo "as" | cec-client -s -d 1
fi
elif [ "${ACTION}" = "onpoweroff" ] && [ "$CEC_ONPOWEROFF_STANDBY" = true ]; then
echo "standby $CEC_TVID" | cec-client -s -d 1
elif [ "${ACTION}" = "onsleep" ] && [ "$CEC_ONSLEEP_STANDBY" = true ]; then
echo "standby $CEC_TVID" | cec-client -s -d 1
fi