Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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'
share|improve this answer
Thanks, didn't know that. I'll try this when I get home. Looks very promising. – Budric Aug 17 '12 at 15:47
Unfortunately xrandr shows "DFP1 connected" even when TV is off. – Budric Aug 18 '12 at 19:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.