support options and add VERSION
This commit is contained in:
parent
63603a40d0
commit
b930d84a70
3 changed files with 54 additions and 6 deletions
4
Makefile
4
Makefile
|
@ -1,5 +1,7 @@
|
||||||
.POSIX:
|
.POSIX:
|
||||||
|
|
||||||
|
VERSION =0
|
||||||
|
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
|
|
||||||
PKG_CONFIG = pkg-config
|
PKG_CONFIG = pkg-config
|
||||||
|
@ -8,7 +10,7 @@ PKGS = wayland-client fcft pixman-1
|
||||||
INCS = `$(PKG_CONFIG) --cflags $(PKGS)`
|
INCS = `$(PKG_CONFIG) --cflags $(PKGS)`
|
||||||
LIBS = `$(PKG_CONFIG) --libs $(PKGS)`
|
LIBS = `$(PKG_CONFIG) --libs $(PKGS)`
|
||||||
|
|
||||||
DAMCPPFLAGS = -D_GNU_SOURCE
|
DAMCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_GNU_SOURCE
|
||||||
DAMCFLAGS = -pedantic -Wall $(INCS) $(DAMCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
|
DAMCFLAGS = -pedantic -Wall $(INCS) $(DAMCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
|
||||||
LDLIBS = $(LIBS)
|
LDLIBS = $(LIBS)
|
||||||
|
|
||||||
|
|
4
config.h
4
config.h
|
@ -1,6 +1,6 @@
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static const int showbar = 1; /* 0 means no bar */
|
static int showbar = 1; /* 0 means no bar */
|
||||||
static const int topbar = 1; /* 0 means bottom bar */
|
static int topbar = 1; /* 0 means bottom bar */
|
||||||
static const char *fonts[] = { "monospace:size=10" };
|
static const char *fonts[] = { "monospace:size=10" };
|
||||||
static uint32_t colors[][3] = {
|
static uint32_t colors[][3] = {
|
||||||
/* fg bg */
|
/* fg bg */
|
||||||
|
|
52
dam.c
52
dam.c
|
@ -1,15 +1,13 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
#define _POSIX_C_SOURCE 200809L
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <linux/input-event-codes.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <linux/input-event-codes.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/signalfd.h>
|
#include <sys/signalfd.h>
|
||||||
#include <poll.h>
|
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
|
@ -106,6 +104,21 @@ die(const char *fmt, ...)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
parse_color(uint32_t *dest, const char *src)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if (src[0] == '#')
|
||||||
|
src++;
|
||||||
|
len = strlen(src);
|
||||||
|
if (len != 6 && len != 8)
|
||||||
|
die("bad color: %s", src);
|
||||||
|
|
||||||
|
*dest = strtoul(src, NULL, 16);
|
||||||
|
if (len == 6)
|
||||||
|
*dest = (*dest << 8) | 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bar_deinit_surface(Bar *bar)
|
bar_deinit_surface(Bar *bar)
|
||||||
|
@ -696,9 +709,42 @@ cleanup(void)
|
||||||
wl_display_disconnect(display);
|
wl_display_disconnect(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
die("usage: dam [-st] [-f font] [-nb color] [-nf color] [-sb color] [-sf color]\n");
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
/* these options take no arguments */
|
||||||
|
if (!strcmp(argv[i], "-v")) {
|
||||||
|
puts("dam-"VERSION);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
} else if (!strcmp(argv[i], "-s"))
|
||||||
|
showbar = !showbar;
|
||||||
|
else if (!strcmp(argv[i], "-t"))
|
||||||
|
topbar = !showbar;
|
||||||
|
else if (i + 1 == argc)
|
||||||
|
usage();
|
||||||
|
else if (!strcmp(argv[i], "-f"))
|
||||||
|
fonts[0] = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-nb"))
|
||||||
|
parse_color(&colors[SchemeNorm][ColBg], argv[++i]);
|
||||||
|
else if (!strcmp(argv[i], "-nf"))
|
||||||
|
parse_color(&colors[SchemeNorm][ColFg], argv[++i]);
|
||||||
|
else if (!strcmp(argv[i], "-sb"))
|
||||||
|
parse_color(&colors[SchemeSel][ColBg], argv[++i]);
|
||||||
|
else if (!strcmp(argv[i], "-sf"))
|
||||||
|
parse_color(&colors[SchemeSel][ColFg], argv[++i]);
|
||||||
|
else
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
run();
|
run();
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
Loading…
Add table
Reference in a new issue