Skip to content

A Go library for terminal background color detection

License

Notifications You must be signed in to change notification settings

anz-bank/go-termbg

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-termbg

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.

Verified terminals

If you check other terminals, please report through issue.

Unsupported terminals

"Windows Terminal" may be supported in a future release: microsoft/terminal#3718.

Check program

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

Detecting mechanism

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".

About

A Go library for terminal background color detection

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%