I added an external monitor to my laptop last week and have almost everything working like I want except for the Brightness & Lock behavior.
I've long had this set to "Turn screen off when inactive for: 5 minutes" and it works like a charm for the laptop screen - both before and after the addition of the external monitor. But it doesn't work on the external monitor. When I'm away from my desk for longer than I intended, I come back to a black laptop screen and the locked screen and login input on the external monitor.
The issue seems similar to this question, but in that one it appears that it's the primary monitor not going black. Which is why I'm posting this as a separate question.
Yes, I know I can turn the monitor's power off, and I do at night, but I'd like it to go black in synch with the native screen if possible.
I'm on 14.04. The monitor is connected via HDMI. The laptop is a VAIO with a little age on it now.
As a follow-up, when I tested the bash script in the accepted answer, I set a low timeout, ran the script from a terminal, watched both monitors dim to black, and then accepted the answer. Subsequently, I actually added the script (with a re-set timeout) to my startup scripts and bounced my machine.
After my first longer-than-expected absence, imagine my surprise when I came back to my desk to find my external monitor shining brightly!
Subsequent research has shown that this is likely caused by the HDMI monitor itself, and no script is going to fix it. Indeed, I've (accidentally) been at my desk when this script kicked in. Both monitors go black as they should, and then about a minute later, the external monitor turns itself back on. :-(
Oh well. I tried.