Skip to content

Instantly share code, notes, and snippets.

@pschichtel
Last active January 1, 2021 19:33
Show Gist options
  • Save pschichtel/fa46d49024dfb24c22c7bd2ce11e5b06 to your computer and use it in GitHub Desktop.
Save pschichtel/fa46d49024dfb24c22c7bd2ce11e5b06 to your computer and use it in GitHub Desktop.
Small script to control a screen using CEC
#!/usr/bin/env bash
device="${CEC_DEVICE:-0.0.0.0}"
command="${1?no command given}"
case "$command" in
on)
cec_command="on $device"
;;
off)
cec_command="standby $device"
;;
*)
echo "Unknown command $command!" 1>&2
exit 1
esac
echo "$cec_command" | cec-client -s -d 1
# Turn on at 08:00 on every workday and turn off at 19:00 on every workday
0 8 * * 1-5 control_screen on >/dev/null 2>&1
0 19 * * 1-5 control_screen off >/dev/null 2>&1
@nucleare
Copy link

nucleare commented Jan 1, 2021

by any chance would you be familiar with the CEC command for Remote Control Pass Through and in conjunction with that, possibly the
command for Picture or aspect ratio? Whereby I'm hoping to change the picture settings to account for overscan because I do not have a remote to do so, although since it is a "hospitality version" TV, I'm not sure if CEC commands would work but I would assume so.

(Based on a prior stay, when the hotel property sent their IT person, they simply brought a different style remote that looked like it was specific to the Samsung TV instead of the hotel provided remote in the room, which connects to the DVR/universal-remote-style-looking thing and only controls volume and power on the TV, to access the menu options and quickly fixed it for me. so I'm presuming if I had brought a universal remote that could be programmed to the TV, I could do the same thing, but I wouldn't know the correct code for programming it correctly)
But that;s why I'm wondering if I can send a similar command, such as one equivalent to the "Picture" key, using this script to accomplish that same goal of enabling overscan.

@pschichtel
Copy link
Author

@nucleare nope, sorry. I haven't looked into this much beyond my use-case of turning the screen on and off using a cronjob.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment