A Go library for terminal background color detection. The detected color is provided by RGB or theme ( dark or light ).
Based on https://github.com/dalance/termbg for Rust
This is a temporary fork due to a problem with v0.3.0 having a bug when you go get it directly.
- Alacritty
- GNOME Terminal
- GNU Screen
- kitty
- iTerm2
- macOS terminal
- MATE Terminal
- mintty
- RLogin
- rxvt-unicode
- sakura
- PuTTY PRIVATE PATCHES
- Tera Term
- Terminator
- tmux
- xfce4-terminal
- xterm
- Win32 console
If you check other terminals, please report through issue.
"Windows Terminal" may be supported in a future release: microsoft/terminal#3718.
This module provides a simple program to check.
$ go run ./...
Check terminal background color
Term : XtermCompatible
Color: R=2e2e, G=3434, B=3636
Theme: Dark
If the terminal is win32 console, WIN32API is used for detection. If the terminal is xterm compatible, "Xterm Control Sequences" is used.
The detected RGB is converted to YCbCr. If Y > 0.5, the theme is detected as "light", otherwise "dark".