Open zeenix opened 1 month ago
Edit: I re-read my original comment and felt that a rewrite was appropriate as I feel that I came across as defeatist. That's not how I want to interact with people!
It's really cool to see you interested in my profile and terminal-colorsaurus
in particular :))
Although a lot of passion and sweat went into the library I would
generally recommend trying other things first before reaching for a tool such as terminal-colorsaurus
.
Detecting the background color from the terminal comes with some pitfalls (one of these you have already experienced with the polling issue on macOS), namely:
Advantages of terminal-colorsaurus
:
I think the biggest advantage of terminal-colorsaurus
over other libraries is that it doesn't use a fixed timeout for queries. This is most noticeable when querying for the bg color is not supported.
One or two terminals out there respond with a different format and terminal-colorsaurus
knows how to handle that.
terminal-colorsaurus
is also careful to not query the terminal when the TERM
env var is not set or set to TERM=dumb
.
My recommendation: The differences between dark and light mode in your case could probably be solved by using the default foreground color (instead of black or white). The green color should be fine as the 16 ANSI Colors are usually adapted for dark and light mode (or any other theme).
Making the color "grayed out" could be achieved by using the dimmed style. Support and implementation vary a bit between terminals but are always in the spirit of "dimmed".
If you like, I can open a PR that includes screenshots of dark and light mode in different terminals :)
Totally forgot to address the /dev/tty thing on macOS 😆 Yes, colorsaurus deals with that by using pselect instead of poll. Most of the time this isn't relevant because I try to re-use one of the open file descriptors (either stdout, stderr or stdin).
@bash While reviewing your zbus PR, I looked at your profile (standard practice after the xz fiasco :laughing:) and found your terminal-colorsaurus project. In gimoji, I've been using
terminal-light
(based onxterm-query
). I wonder if there would be some advantages of switching to terminal-colorsaurus? For one, it seems you've already been aware of the "polling of /dev/tty on MacOs" issue (and I assume you've it addressed?) so if I had usedtermina-colorsaurus
from the beginning, it would have saved me a lot of time, debugging and then fixing that. But I wonder if there is an advantage still? :thinking: