rocky / shell-term-background

POSIX shell scripts to figure out if a terminal has a dark or light background
GNU General Public License v2.0
35 stars 4 forks source link

is_dark_rgb comparison value seems wrong #2

Closed ulope closed 5 years ago

ulope commented 5 years ago

(Unfortunately I've so far only been able to test this on one terminal)

It looks to me that the comparison value used in the is_dark_rgb function is wrong.

The RGB values returned from my terminal (iTerm2) are all between 0x00 and 0xff and therefore R+B+G is always smaller then (.6 * (0xffff * 3)) leading to the script always reporting dark mode.

rocky commented 5 years ago

A real xterm allows R, G, or B values up to 0xffff. xterm-256color seems to allow only up to 0xff.

Try the code in branch TERMINAL_COLOR_MIDPOINT. If that works, I'll push that to the master branch.