ctemp

Set color temperature
git clone git://git.akobets.xyz/ctemp
Log | Files | Refs | README | LICENSE

commit c8b3f3a89eac7b15e76d68541d4c9cb5f7a94680
parent 79ba780a588e183b93c984b9aedd0c40484be5a3
Author: Artem Kobets <artem@akobets.xyz>
Date:   Wed,  4 Mar 2020 19:56:37 +0200

remove default interface

Diffstat:
MMakefile | 5+----
Dconfig.def.h | 2--
Mctemp.c | 25++++++++++---------------
3 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/Makefile b/Makefile @@ -8,15 +8,12 @@ OBJ = $(SRC:.c=.o) all: ctemp -config.h: - cp config.def.h config.h - .c.o: $(CC) -o $@ -c $< $(CFLAGS) $(OBJ): config.mk util.h -ctemp: config.h $(OBJ) +ctemp: $(OBJ) $(CC) -o $@ $(OBJ) $(LDFLAGS) clean: diff --git a/config.def.h b/config.def.h @@ -1,2 +0,0 @@ -/* use this interface if -i flag is not specified */ -#define DEFAULT_INTERFACE "x" diff --git a/ctemp.c b/ctemp.c @@ -47,8 +47,6 @@ Interface interfaces[] = { #endif }; -#include "config.h" - extern const struct { float r; float g; float b; } whitepoints[]; char *argv0; @@ -254,13 +252,11 @@ usage() } die( - "usage: %s [-i interface] temperature\n" - " interface - one of [%s]" - " (default - %s)\n" + "usage: %s -i interface temperature\n" + " interface - one of [ %s ]\n" " temperature - %i-%i, with interval %i, rounded down" " (initial value is usually 6500)\n", - argv0, ifStr, DEFAULT_INTERFACE, - TEMP_MIN, TEMP_MAX, TEMP_INTERVAL + argv0, ifStr, TEMP_MIN, TEMP_MAX, TEMP_INTERVAL ); } @@ -277,9 +273,13 @@ main(int argc, char **argv) { case 'i': { if_name = EARGF(usage()); for (i = 0; i < LEN(interfaces); i++) { - if (strcmp(if_name, interfaces[i].name) == 0) + if (strcmp(if_name, interfaces[i].name) == 0) { handler = interfaces[i].handler; + break; + } } + if (handler == NULL) + usage(); break; } case 'v': @@ -290,13 +290,8 @@ main(int argc, char **argv) { break; } ARGEND - if (handler == NULL) { - for (i = 0; i < LEN(interfaces); i++) { - if (strcmp(DEFAULT_INTERFACE, interfaces[i].name) == 0) { - handler = interfaces[i].handler; - } - } - } + if (handler == NULL && LEN(interfaces) == 1) + handler = interfaces[0].handler; if (handler == NULL) usage();