I’m extremely lazy, so using a remote control to switch the TV on or off is just out of the question. The remote is just languishing in a cupboard somewhere, and the TV is always on. Which seems like a waste, since I only use it (like) a couple of days a week or something.
Most of the time it just functions as an xscreensaver-enabled display to show the sleeve of whatever album’s playing on the stereo.
But then! The other week a friend told me about something magical called “CEC”, which is apparently short for Consumer Electronics Control. It allows sending commands via HDMI (High-Definition Multimedia Interface) from your VIDEO (Visual Ideas Directed Except Oldskool) card to the TV (Television).
However, virtually no video cards support this natively. The notable exception is the graphics card in the Raspberry Pi (RPI).
Fortunately, Pulse-Eight sells CEC injectors. It a tiny thing you put in between your computer and your TV. And today it arrived:
Very small and cute.
It’s a bit more extensive with the wiring. The product page said that you can’t use it reliably if you have a very long HDMI cable to your TV, but mine is seven meters, and it seems to work fine… Oh, perhaps I should try playing something that takes a lot of bandwidth… Let’s see… Captain America: Civil War Bluray… Yup, there’s the captain. No extra latency or anything that as far as I can tell.
There’s a USB port that you communicate over. The device shows up as a serial device in Linux, and you talk to it via a program called cec-client.
This excellent blog posts details how you use cec-client from Linux, but basically you just say
$ echo 'standby 0' | cec-client -s /dev/ttyACM0
and the TV goes to standby mode.
OR DOES IT?
Mine didn’t, and it’s a five year old Samsung TV. After googling a bit more, it turns out that you have to enable this stuff under the “Anynet+” setting in the menus. Let’s just walk through this quickly, if anybody has problems finding the menu (which is something I had):
It’s way down in the main menu. Enter the “Content View” thing…
… and then choose “Anynet+”…
… and setup..
… and the thing you’re looking for is “Auto Turn Off”. If that’s on, then you can put the TV into standby mode via CEC. Makes sense, huh? HUH?!
So now all the bits are in place, and I can use this stuff. I chose to have xscreensaver wake the screen up with a -watch script modeled after this one.
So when I hit something on the TV machine keyboard, it unblanks xscreensaver and turns the TV on. (This takes an annoyingly long time, though… like 10 seconds? What’s up with TV makers and the incredible slowness involved with anything?)
To switch the TV off, I just hooked it up into my general go out/switch off everything before going to sleep actions.
Emacs is for automation.
There you go.