diff --git a/README.md b/README.md index f789352..99dc241 100644 --- a/README.md +++ b/README.md @@ -34,15 +34,19 @@ tuxrecord2 # Record for N seconds tuxrecord2 -d 30 +tuxrecord2 --duration 30 # Specify output directory tuxrecord2 -o /path/to/dir +tuxrecord2 --output /path/to/dir # Use a custom filename prefix tuxrecord2 -p myrec +tuxrecord2 --prefix myrec # Use a specific ALSA capture device tuxrecord2 -D hw:1,0 +tuxrecord2 --device hw:1,0 # Encode to FLAC (lossless) or MP3 (lossy) in real time tuxrecord2 -f flac @@ -54,14 +58,14 @@ tuxrecord2 -D pipewire ## Options -| Option | Description | -| -------------- | -------------------------------------------------------- | -| `-o ` | Output directory (default: current directory) | -| `-d ` | Stop automatically after `` seconds | -| `-p ` | Filename prefix instead of `tuxrecord2` | -| `-D ` | ALSA capture device (default: `default`; `pipewire` on PipeWire systems) | -| `-f, --format ` | Output format: `wav`, `flac` or `mp3` (default: `wav`) | -| `-h, --help` | Show help | +| Option | Description | +| ----------------------- | -------------------------------------------------------- | +| `-o, --output ` | Output directory (default: current directory) | +| `-d, --duration ` | Stop automatically after `` seconds | +| `-p, --prefix ` | Filename prefix instead of `tuxrecord2` | +| `-D, --device ` | ALSA capture device (default: `default`; `pipewire` on PipeWire systems) | +| `-f, --format ` | Output format: `wav`, `flac` or `mp3` (default: `wav`) | +| `-h, --help` | Show help | Run `arecord -l` to list available ALSA capture devices. On systems with PipeWire, list the PipeWire source nodes with `pactl list short sources` diff --git a/src/main.rs b/src/main.rs index d1f9e63..ca2f0f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -84,12 +84,12 @@ fn usage() { \x20 tuxrecord2 [options]\n\ \n\ OPTIONS\n\ - \x20 -o Output directory (default: current directory)\n\ - \x20 -d Stop automatically after seconds (default: until q or Ctrl+C)\n\ - \x20 -p Filename prefix instead of \"{prefix}\" (default: {prefix})\n\ - \x20 -D ALSA capture device (default: \"{device}\")\n\ - \x20 -f, --format F Output format: {formats} (default: {format})\n\ - \x20 -h, --help Show this help\n\ + \x20 -o, --output Output directory (default: current directory)\n\ + \x20 -d, --duration Stop automatically after seconds (default: until q or Ctrl+C)\n\ + \x20 -p, --prefix Filename prefix instead of \"{prefix}\" (default: {prefix})\n\ + \x20 -D, --device ALSA capture device (default: \"{device}\")\n\ + \x20 -f, --format Output format: {formats} (default: {format})\n\ + \x20 -h, --help Show this help\n\ \n\ The file is written as __. where is wav, flac, or mp3.\n\ \n\ @@ -425,8 +425,9 @@ fn timestamp() -> String { /* * Program entry point: parse options, record audio, encode the output. * - * Parses the command line (-o dir, -d seconds, -p prefix, -D device, - * -f/--format, -h/--help), validates the output directory, builds the + * Parses the command line (-o/--output dir, -d/--duration seconds, + * -p/--prefix prefix, -D/--device device, -f/--format, -h/--help), + * validates the output directory, builds the * output filename "/__." and opens the ALSA * capture device and the output encoder. It then installs SIGINT/SIGTERM * handlers and runs a poll() loop that reads captured PCM frames from ALSA @@ -449,7 +450,7 @@ fn run() -> i32 { let mut i = 1; while i < args.len() { match args[i].as_str() { - "-o" => { + "-o" | "--output" => { i += 1; if i >= args.len() { usage(); @@ -457,7 +458,7 @@ fn run() -> i32 { } output_dir = args[i].clone(); } - "-d" => { + "-d" | "--duration" => { i += 1; if i >= args.len() { usage(); @@ -471,7 +472,7 @@ fn run() -> i32 { } } } - "-p" => { + "-p" | "--prefix" => { i += 1; if i >= args.len() || args[i].is_empty() { usage(); @@ -479,7 +480,7 @@ fn run() -> i32 { } prefix = args[i].clone(); } - "-D" => { + "-D" | "--device" => { i += 1; if i >= args.len() || args[i].is_empty() { usage();