{"id":24756344,"url":"https://github.com/dalance/termbg","last_synced_at":"2025-05-16T05:05:35.707Z","repository":{"id":44569583,"uuid":"311298576","full_name":"dalance/termbg","owner":"dalance","description":"A Rust library for terminal background color detection","archived":false,"fork":false,"pushed_at":"2025-04-09T01:56:37.000Z","size":95,"stargazers_count":96,"open_issues_count":9,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-10T20:04:16.170Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dalance.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"dalance"}},"created_at":"2020-11-09T10:13:52.000Z","updated_at":"2025-04-26T19:53:19.000Z","dependencies_parsed_at":"2025-01-28T13:51:18.872Z","dependency_job_id":"828aa4b5-e340-4582-80fe-9f75ac103f44","html_url":"https://github.com/dalance/termbg","commit_stats":{"total_commits":41,"total_committers":2,"mean_commits":20.5,"dds":0.04878048780487809,"last_synced_commit":"e9ca93d2a0c44fef53d667031fa72ed7d5bd2c06"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalance%2Ftermbg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalance%2Ftermbg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalance%2Ftermbg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dalance%2Ftermbg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dalance","download_url":"https://codeload.github.com/dalance/termbg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471061,"owners_count":22076585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-28T13:51:05.780Z","updated_at":"2025-05-16T05:05:35.689Z","avatar_url":"https://github.com/dalance.png","language":"Rust","funding_links":["https://github.com/sponsors/dalance"],"categories":[],"sub_categories":[],"readme":"# termbg\nA Rust library for terminal background color detection.\nThe detected color is provided by RGB or theme ( dark or light ).\n\n[![Actions Status](https://github.com/dalance/termbg/workflows/Rust/badge.svg)](https://github.com/dalance/termbg/actions)\n[![Crates.io](https://img.shields.io/crates/v/termbg.svg)](https://crates.io/crates/termbg)\n[![Docs.rs](https://docs.rs/termbg/badge.svg)](https://docs.rs/termbg)\n\n## Verified terminals\n\n* [Alacritty](https://github.com/alacritty/alacritty)\n* GNOME Terminal\n* GNU Screen\n* [kitty](https://sw.kovidgoyal.net/kitty/)\n* [iTerm2](https://iterm2.com)\n* macOS terminal\n* MATE Terminal\n* [mintty](https://mintty.github.io)\n* [RLogin](http://nanno.dip.jp/softlib/man/rlogin/)\n* rxvt-unicode\n* sakura\n* [PuTTY PRIVATE PATCHES](https://ice.hotmint.com/putty/)\n* [Tera Term](https://ttssh2.osdn.jp)\n* [Terminator](https://terminator-gtk3.readthedocs.io/en/latest/)\n* [tmux](https://github.com/tmux/tmux)\n* [Visual Studio Code](https://code.visualstudio.com)\n* xfce4-terminal\n* xterm\n* Win32 console\n\nIf you check other terminals, please report through [issue](https://github.com/dalance/termbg/issues).\n\n## Unsupported terminals\n\n* [Cmder](https://cmder.app)\n* [ConEmu](https://conemu.github.io)\n* [LilyTerm](https://github.com/Tetralet/LilyTerm)\n* [Poderosa](https://ja.poderosa-terminal.com)\n* [PuTTY](https://www.putty.org)\n* [QTerminal](https://github.com/lxqt/qterminal)\n* [Windows Terminal](https://github.com/microsoft/terminal)\n\n\"Windows Terminal\" may be supported in a future release: https://github.com/microsoft/terminal/issues/3718.\n\n## Usage\n\n```Cargo.toml\n[dependencies]\ntermbg = \"0.6.2\"\n```\n\n## Example\n\n```rust\nfn main() {\n    let timeout = std::time::Duration::from_millis(100);\n\n    println!(\"Check terminal background color\");\n    let term = termbg::terminal();\n    let rgb = termbg::rgb(timeout);\n    let theme = termbg::theme(timeout);\n\n    println!(\"  Term : {:?}\", term);\n\n    match rgb {\n        Ok(rgb) =\u003e {\n            println!(\"  Color: R={:x}, G={:x}, B={:x}\", rgb.r, rgb.g, rgb.b);\n        }\n        Err(e) =\u003e {\n            println!(\"  Color: detection failed {:?}\", e);\n        }\n    }\n\n    match theme {\n        Ok(theme) =\u003e {\n            println!(\"  Theme: {:?}\", theme);\n        }\n        Err(e) =\u003e {\n            println!(\"  Theme: detection failed {:?}\", e);\n        }\n    }\n}\n```\n\n## Check program\n\nThis crate provides a simple program to check.\n\n```console\n$ cargo run --example termbg\nCheck terminal background color\n  Term : Tmux\n  Color: R=0, G=0, B=0\n  Theme: Dark\n```\n\n## Detecting mechanism\n\nIf the terminal is win32 console, WIN32API is used for detection.\nIf the terminal is xterm compatible, \"Xterm Control Sequences\" is used.\nWhen these method was failed, `COLORFGBG` environment variable is used.\n\nThe detected RGB is converted to YCbCr.\nIf Y \u003e 0.5, the theme is detected as \"light\", otherwise \"dark\".\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalance%2Ftermbg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdalance%2Ftermbg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdalance%2Ftermbg/lists"}