nausea

curses audio visualizer
git clone git://git.2f30.org/nausea
Log | Files | Refs | README | LICENSE

commit 74fb81c81f0313fd84192b050b05c16232365620
parent fbca546f1b521934ccab2410d68c6ce48426469b
Author: sin <sin@2f30.org>
Date:   Mon, 18 Nov 2013 11:47:18 +0000

Default to `/tmp/mpd.fifo' - add rudimentary argument passing

Diffstat:
MREADME | 8++++++--
Mspectrum.c | 27+++++++++++++++++++++++----
2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/README b/README @@ -10,12 +10,16 @@ because it's the only one supported for now. audio_output { type "fifo" name "Pipe" - path "~/.mpd/mpd.fifo" + path "/tmp/mpd.fifo" format "44100:16:1" } Then start spectrum with: - $ spectrum ~/.mpd/mpd.fifo + $ spectrum + +or specify the path of your mpd fifo with: + + $ spectrum <path-to-fifo> Enjoy! diff --git a/spectrum.c b/spectrum.c @@ -28,7 +28,8 @@ int bits = 16; int channels = 1; char symbol = '|'; int die = 0; -char *fname = NULL; +char *fname = "/tmp/mpd.fifo"; +char *argv0; struct frame { int fd; @@ -135,15 +136,33 @@ spectrum_draw(struct frame *fr) refresh(); } +static void +usage(void) +{ + fprintf(stderr, "usage: %s [-h] [mpdfifo]\n", argv0); + fprintf(stderr, "fifo default path is `/tmp/mpd.fifo'\n"); + exit(1); +} + int main(int argc, char *argv[]) { int c, i; struct frame fr; - if (argc != 2) - errx(1, "usage: %s mpdfifo", argv[0]); - fname = argv[1]; + argv0 = argv[0]; + while (--argc > 0 && (*++argv)[0] == '-') + while ((c = *++argv[0])) + switch (c) { + case 'h': + /* fall-through */ + default: + usage(); + } + if (argc == 1) + fname = argv[0]; + else if (argc > 1) + usage(); /* init fftw3 */ memset(&fr, 0, sizeof(fr));