GithubHelp home page GithubHelp logo

termbg's People

Contributors

aykevl avatar dalance avatar dependabot-preview[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

termbg's Issues

Environment variable fallback for unsupported terminals

For unsupported terminals it would be nice to have some fallback.

According to https://unix.stackexchange.com/questions/245378/common-environment-variable-to-set-dark-or-light-terminal-background / https://github.com/rocky/shell-term-background there's no well-established standard, but the COLORFGBG environment variable has some potential: Value 15;0 is for a dark background (technically white on black) and 0;15 (technically black on white) is for a light background.

Would you be willing to adopting this?

Incorrect colors and "Dark" state for macOS Terminal.app with default theme

termbg is pretty great and easy to use / test via cargo run.

However, I noticed that when using macOS Terminal.app, with the default profile ("Basic"), the results are incorrect.

It seems that termbg (or one of its dependencies) does not take into account the macOS systemwide appearance, which changes the color of the default terminal from white (Light mode) to black (Dark mode). This setting may change at any time, and can be fetched with:

$ defaults read -globalDomain AppleInterfaceStyle
# prints "Dark" or nothing

Note that this is the ONLY Terminal.app Profile which behaves this way (AFAIK).

Examples

Screen Shot 2021-07-21 at 4 00 03 AM

Screen Shot 2021-07-21 at 3 58 47 AM

Feature: Homebrew Intallation

It would be neat if termbg were installable via brew install termbg.

This would allow me to e.g. write shell scripts which have different color schemes for different background colors. For example, using yellow text to indicate a warning works on a dark background -- but is hard to read on a white background.

Tmux does not appear to work

Tmux is listed as one of the verified terminals, but for me it doesn't actually work:

With a dark background:

$ ./src/misc/termbg/target/release/termbg 
Check terminal background color
  Term : Tmux
  Latency: 630.001µs
  Color: R=0, G=0, B=0
  Theme: Dark

And with a light background:

$ ./src/misc/termbg/target/release/termbg 
Check terminal background color
  Term : Tmux
  Latency: 1.319794ms
  Color: R=0, G=0, B=0
  Theme: Dark

In both cases the detection appears to be error-free, but the background is detected incorrectly as dark.

Outside tmux (in a plain Konsole window), the color is detected correctly:

~$ ./src/misc/termbg/target/release/termbg 
Check terminal background color
  Term : XtermCompatible
  Latency: 1.449628ms
  Color: R=0, G=0, B=0
  Theme: Dark

~$ ./src/misc/termbg/target/release/termbg
Check terminal background color
  Term : XtermCompatible
  Latency: 2.596755ms
  Color: R=ffff, G=ffff, B=ffff
  Theme: Light

Interestingly, the color is detected correctly inside screen:

~$ ./src/misc/termbg/target/release/termbg
Check terminal background color
  Term : Screen
  Latency: 891.835µs
  Color: R=ffff, G=ffff, B=ffff
  Theme: Light

~$ ./src/misc/termbg/target/release/termbg
Check terminal background color
  Term : Screen
  Latency: 867.376µs
  Color: R=0, G=0, B=0
  Theme: Dark

Note that the tmux color isn't even recognized when the terminal is explicitly set to a particular color from within tmux:

~$ tmux set window-style 'fg=#d0cfcc,bg=#171421'

~$ ./src/misc/termbg/target/release/termbg
Check terminal background color
  Term : Tmux
  Latency: 409.917µs
  Color: R=0, G=0, B=0
  Theme: Dark

~$ tmux set window-style 'fg=#171421,bg=#ffffff'

~$ ./src/misc/termbg/target/release/termbg
Check terminal background color
  Term : Tmux
  Latency: 669.626µs
  Color: R=0, G=0, B=0
  Theme: Dark

Related: tmux/tmux#1919

Can't get the background color in neovim terminal emulator

From the documentation, we know that neovim embeds a VT220/xterm terminal emulator based on libvterm.
But, termbg currently can't get background color in neovim terminal emulator.

Environment:

  • Neovim version: v0.5.0-dev

Reproduce step:

  1. Open neovim without config file: nvim -u NONE
  2. Open terminal in neovim via :terminal
  3. Run cargo run in nvim terminal emulator

The output is:

Check terminal background color
  Term : XtermCompatible
  Color: detection failed Timeout { source: Timeout }
  Theme: detection failed Timeout { source: Timeout }

ConEmu / Cmder support?

https://conemu.github.io/ is a popular terminal replacement on Windows, which works by hiding the "real console" and re-rendering its contents in a ConEmu window.

ConEmu lets the user set up color schemes, which are applied when drawing to the ConEmu window, so termbg does not detect them, reporting the color of the "real console" instead. Same goes for Cmder, which relies on ConEmu under the hood.

Since ConEmu already has some support for xterm codes, we would probably need ConEmu to add support for querying the color scheme, similarly to microsoft/terminal#3718.

In the meantime, could it be added to the "unsupported" list in the README?

Release stdin if unable to get background

termbg should release stdin if unable to get background colour for xterm. Currently, it returns an error, but the thread querying the colour continues to hold onto stdin and runs in the background. This does not let other threads lock on stdin.

Bytes leak when `]11` OSC is used to get background color.

When "\x1b]11;?\x1b\\" is used to query the background color, the loop reading stdin breaks after receiving the 0x1b byte. But there is still one byte left in stdin to be read (In my case 0x5c) which causes problems if I try to read stdin after this.
I'm not sure if this also happens in the other two cases as well.

termbg/src/lib.rs

Lines 175 to 181 in 6a1bdcb

let query = if term == Terminal::Tmux {
"\x1bPtmux;\x1b\x1b]11;?\x07\x1b\\\x03"
} else if term == Terminal::Screen {
"\x1bP\x1b]11;?\x07\x1b\\\x03"
} else {
"\x1b]11;?\x1b\\"
};

I'm running bash in alacritty.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.