diff --git a/Cargo.lock b/Cargo.lock
@@ -932,7 +932,7 @@ dependencies = [
[[package]]
name = "ommp"
-version = "0.1.0"
+version = "0.1.1"
dependencies = [
"anyhow",
"crossbeam-channel",
diff --git a/Cargo.toml b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ommp"
-version = "0.1.0"
+version = "0.1.1"
edition = "2021"
authors = ["sqzer-x"]
description = "Oh My Music Player — a terminal music player built with ratatui"
@@ -10,7 +10,7 @@ keywords = ["music", "player", "tui", "terminal", "ratatui"]
categories = ["command-line-utilities", "multimedia::audio"]
# 1.2 MB that everyone installing the crate would download, for an image
# crates.io cannot resolve from a relative README path anyway.
-exclude = ["assets/screenshot.png"]
+exclude = ["assets/screenshot.png", "packaging"]
[dependencies]
ratatui = "0.29"
diff --git a/src/main.rs b/src/main.rs
@@ -14,6 +14,7 @@ use crossterm::{
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
+use crossterm::tty::IsTty;
use ratatui::backend::CrosstermBackend;
use ratatui::Terminal;
@@ -51,6 +52,19 @@ fn restore_terminal() {
}
fn main() -> Result<()> {
+ // Raw mode fails with a bare "No such device or address" when stdin or
+ // stdout is not a terminal, which says nothing about what to do.
+ if !io::stdin().is_tty() || !io::stdout().is_tty() {
+ eprintln!("ommp is a full-screen terminal application and needs an interactive terminal.");
+ eprintln!();
+ eprintln!("Run it directly in your terminal:");
+ eprintln!();
+ eprintln!(" ommp");
+ eprintln!();
+ eprintln!("It cannot run through a pipe, a redirect, or a non-interactive shell.");
+ std::process::exit(1);
+ }
+
setup_terminal()?;
// Restore before the default hook prints: a panic message written while the
|