[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Background color detection

From: Rick Richardson
Subject: Background color detection
Date: Tue, 13 May 2003 11:18:23 -0500
User-agent: Mutt/

I have an application that currently has 4 color modes that the
user can control from the command line:

    mode 0:     force the background of the terminal to black
    mode 1:     force the background of the terminal to white
    mode 2:     use_default_colors (assume my background is "darkish")
    mode 3:     use_default_colors (assume my background is "whiteish")

This lets my application attempt to select color pairs with good
contrast, while still allowing the user to have some control over
their background color preference.

This application is most likely to be running under either a Linux
console, or one of the various terminal emulators (xterm, gnome-
terminal, konsole).  I'd like to add another mode, and make it
the default:
    mode 4:     autodetect user's background color and use_default_colors

This mode would (somehow) query the underlying terminal emulator to find
out what color the background is, then compute the luminosity of
that background and then switch into either mode 2 or mode 3, as

Has anybody tried doing something like this?  Anyway to do this
that works "for a large set" of terminal emulators?


Rick Richardson  address@hidden        http://home.mn.rr.com/richardsons/
Stock information at your fingertips:   http://linuxtrade.0catch.com/

I still say awk '{print $1}' a lot. -- Larry Wall

reply via email to

[Prev in Thread] Current Thread [Next in Thread]