Skip to content

Commit

Permalink
Disable termbg at piped/redirected #146
Browse files Browse the repository at this point in the history
  • Loading branch information
dalance committed May 18, 2021
1 parent 60ae1be commit 7cc4e93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased](https://github.com/dalance/procs/compare/v0.11.6...Unreleased) - ReleaseDate

* [Fixed] crash at piped/redirected [#146](https://github.com/dalance/procs/issues/146)
* [Added] elapsed time [#120](https://github.com/dalance/procs/issues/120)
* [Added] completion file message [#130](https://github.com/dalance/procs/issues/130)

Expand Down
17 changes: 11 additions & 6 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,19 @@ pub fn get_theme(opt: &Opt, config: &Config) -> ConfigTheme {
};
match theme {
ConfigTheme::Auto => {
let timeout = Duration::from_millis(100);
if let Ok(theme) = termbg::theme(timeout) {
match theme {
termbg::Theme::Dark => ConfigTheme::Dark,
termbg::Theme::Light => ConfigTheme::Light,
if console::user_attended() {
let timeout = Duration::from_millis(100);
if let Ok(theme) = termbg::theme(timeout) {
match theme {
termbg::Theme::Dark => ConfigTheme::Dark,
termbg::Theme::Light => ConfigTheme::Light,
}
} else {
// If termbg failed, fallback to dark theme
ConfigTheme::Dark
}
} else {
// If termbg failed, fallback to dark theme
// If piped or redirected, fallback to dark theme
ConfigTheme::Dark
}
}
Expand Down

0 comments on commit 7cc4e93

Please sign in to comment.