So run your algorithm over the current content of the framebuffer to work out the amount of "grey" on the screen right now. Then use that as the border.

This could be distracting. If the screen is fading to black, so will your bars. Likewise, if there are rapid MTV-esque cuts between scenes with different lighting, then the bars will change just as fast and become quite distracting. Now, if you wanted to be clever, you could setting the bar to some decaying time average over the past few minutes. I imagine you'd end up with some sort of grey, regardless.

My own TV, like Tony's has the grey level fixed at the factory. My next TV will most likely be DLP or LCD-based, doing away with phosphor burn-in, once and for good.