3

I'm using Ubuntu for an HTPC and I wanted to kill a bunch of processes like the browser when the TV is turned off. This is because I have limited bandwidth and want to avoid chance of streaming content while TV is off, wasting bandwidth.

My solution was to have a cron task run every minute checking for off state. But I'm don't know how to detect HDMI disconnect/TV off.

I've been using this fix: HDMI Audio stops after TV turned off for HDMI sound fix when TV turns off. So I could modify the code such that when ELD_valid switches from 1 to 0, it's time to kill stuff. But I believe it's monitoring sound status over HDMI? Also it seems like a bug fix, so my script would work as long as bug is present?

xrandr looked promising but you have to run it as user connected to a display. So I couldn't test what output it gives when TV is off from an ssh connection.

HDMI CEC codes seemed like another solution but you have to buy an adapter and my TV doesn't support CEC.

Any suggestions? Thanks.

P.S. I'm using ATI catalyst drivers. I'd be happy with ATI specific solution.

Budric
  • 295
  • 2
  • 6
  • 15

1 Answers1

1

xrandr looked promising but you have to run it as user connected to a display.

This is, strictly speaking, not true. It must be able to connect to the X server, but all that requires is 1) the display number, and 2) permission to talk to the X server via the magic cookie or via xauth.

The easiest way to get the cookie is to run as the user that is currently logged onto the display. Giving the display number is as easy as passing $DISPLAY to the program.

sudo -u displayuser env DISPLAY=:0.0 xrandr | grep -q '^xxxx disconnected'
Ignacio Vazquez-Abrams
  • 4,222
  • 1
  • 16
  • 15