Table of Contents
In the Yodeck Portal, the “Turned Off” option provides an easy way to turn off the connected TV screen.
How does it work?
The Yodeck Player (or Raspberry Pi) generally includes a CEC adapter on its HDMI screen/monitor port. If your screen supports HDMI-CEC, then the Player issues a CEC “standby” (or “power on”) command to turn your screen off (or on).
Suppose your TV screen/monitor does not support CEC (e.g., you have a computer monitor. Check out the CEC compatibility chart). In that case, the Player deactivates the HDMI port to allow the TV screen/monitor to power down by itself. This function is supported by all current computer screens/monitors, even some TVs.
How should the custom script behave?
- The script should take 1 command-line argument.
- This argument will always be present.
- It will only have one of two possible values:
on
andoff
- The script should be idempotent. (That is, if it is called twice with the same argument (e.g., on), it should not cause trouble.)
That’s it.
The “standard” script
The script below simulates the standard behavior provided by the Yodeck Player. You can customize this script, add anything you need, and use it.
yodeck_custom_power_script
#!/bin/bash echo 'on 0' | cec-client -s | grep 'not present' > /dev/null NOT_CEC_COMPATIBLE=$? tvservice -s | grep -i 'tv is off' > /dev/null TV_IS_OFF=$? if [ "$1" == "off" ]; then if [ $TV_IS_OFF -eq 0 ]; then echo 'Screen already off, aborting...' exit 0 fi echo 'Turning off screen' if [ $NOT_CEC_COMPATIBLE -ne 0 ]; then echo 'standby 0' | cec-client -s > /dev/null fi tvservice -o elif [ "$1" == "on" ]; then if [ $TV_IS_OFF -ne 0 ]; then echo 'Screen already on, aborting...' exit 0 fi echo 'Turning on screen' FB_DEPTH=$(/bin/fbset | grep 'geometry' | awk '{ print $6 }') tvservice -p fbset -depth 8 fbset -depth $FB_DEPTH xrefresh if [ $NOT_CEC_COMPATIBLE -ne 0 ]; then echo 'on 0' | cec-client -s > /dev/null fi else # Just for debugging, not required or used echo "Screens supports HDMI-CEC: $NOT_CEC_COMPATIBLE" echo "Screens current status: $TV_IS_OFF" echo 'You must specify "on" or "off"' fi
It does not HAVE to be a bash script. You can always provide an executable file or a script in any other language, like Python or Perl. Yodeck will use the contents you provide in Base64 (details below), will write the file to the filesystem, make it executable ( chmod +x
) and call it every time it is required.
Changing the standard script
In your Linux command line, you can use the yodeck_custom_power_script
directive to provide your own custom TV on/off script. To create the custom script entry, run:
echo yodeck_custom_power_script=`base64 -w 0 script_filename.sh`
You should get a player directive (directive_name=base64_encoded_data) ready to be pasted in the Advanced Player Directive field. For the above standard script, that would be:
yodeck_custom_power_script=IyEvYmluL2Jhc2gKCmVjaG8gJ29uIDAnIHwgY2VjLWNsaWVudCAtcyB8IGdyZXAgJ25vdCBwcmVzZW50JyA+IC9kZXYvbnVsbApOT1RfQ0VDX0NPTVBBVElCTEU9JD8KdHZzZXJ2aWNlIC1zIHwgZ3JlcCAtaSAndHYgaXMgb2ZmJyA+IC9kZXYvbnVsbApUVl9JU19PRkY9JD8KCmlmIFsgIiQxIiA9PSAib2ZmIiBdOyB0aGVuCiAgICBpZiBbICRUVl9JU19PRkYgLWVxIDAgXTsgdGhlbgogICAgICAgIGVjaG8gJ1NjcmVlbiBhbHJlYWR5IG9mZiwgYWJvcnRpbmcuLi4nCiAgICAgICAgZXhpdCAwCiAgICBmaQogICAgZWNobyAnVHVybmluZyBvZmYgc2NyZWVuJwogICAgaWYgWyAkTk9UX0NFQ19DT01QQVRJQkxFIC1uZSAwIF07IHRoZW4KICAgICAgICBlY2hvICdzdGFuZGJ5IDAnIHwgY2VjLWNsaWVudCAtcyA+IC9kZXYvbnVsbAogICAgZmkKICAgIHR2c2VydmljZSAtbwplbGlmIFsgIiQxIiA9PSAib24iIF07IHRoZW4KICAgIGlmIFsgJFRWX0lTX09GRiAtbmUgMCBdOyB0aGVuCiAgICAgICAgZWNobyAnU2NyZWVuIGFscmVhZHkgb24sIGFib3J0aW5nLi4uJwogICAgICAgIGV4aXQgMAogICAgZmkKICAgIGVjaG8gJ1R1cm5pbmcgb24gc2NyZWVuJwogICAgRkJfREVQVEg9JCgvYmluL2Zic2V0IHwgZ3JlcCAnZ2VvbWV0cnknIHwgYXdrICd7IHByaW50ICQ2IH0nKQogICAgdHZzZXJ2aWNlIC1wCiAgICBmYnNldCAtZGVwd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