aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2014-08-22 21:15:40 +0000
committerDimitri Sokolyuk <demon@dim13.org>2014-08-22 21:15:40 +0000
commitb74adc8c8eea5b56ac1bf58f0095f8a3322ae138 (patch)
tree5d830b0ee808f715535d9b4c6f074c954974283b
parentd4719e5c1afe21b2f3c6d69c42f845d5ce6ec0e6 (diff)
readd round selector flag
-rw-r--r--spectrogram.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/spectrogram.c b/spectrogram.c
index 294ce1f..31f2c25 100644
--- a/spectrogram.c
+++ b/spectrogram.c
@@ -135,9 +135,10 @@ void
usage(void)
{
fprintf(stderr, "Usage: %s [-dh]\n", __progname);
- fprintf(stderr, "\t-d\tdaemonize\n");
- fprintf(stderr, "\t-f\tfullscreen\n");
- fprintf(stderr, "\t-h\tthis help\n");
+ fprintf(stderr, "\t-d\t\tdaemonize\n");
+ fprintf(stderr, "\t-f\t\tfullscreen\n");
+ fprintf(stderr, "\t-r <round>\tsio round\n");
+ fprintf(stderr, "\t-h\t\tthis help\n");
exit(0);
}
@@ -416,7 +417,7 @@ main(int argc, char **argv)
unsigned long black, white;
float factor = 0.75;
int round = 1024; /* FFT is fastest with powers of two */
- while ((ch = getopt(argc, argv, "dfh")) != -1)
+ while ((ch = getopt(argc, argv, "dfr:h")) != -1)
switch (ch) {
case 'd':
dflag = 1;
@@ -424,6 +425,9 @@ main(int argc, char **argv)
case 'f':
fflag = 1;
break;
+ case 'r':
+ round = atoi(optarg);
+ break;
case 'h':
default:
usage();
@@ -441,14 +445,13 @@ main(int argc, char **argv)
if (!dsp)
errx(1, "Cannot connect to X11 server");
- if (fflag) {
- XGetWindowAttributes(dsp, DefaultRootWindow(dsp), &wa);
+ XGetWindowAttributes(dsp, DefaultRootWindow(dsp), &wa);
+ width = round + HGAP;
+ height = factor * width;
+ if (fflag || width > wa.width || height > wa.height) {
round = wa.width - HGAP;
width = wa.width;
height = wa.height;
- } else {
- width = round + HGAP;
- height = factor * width;
}
sio = init_sio(round);