Skip to content

Commit 7596e4f

Browse files
committed
Re-add version option that prints git sha
1 parent 629a0be commit 7596e4f

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ HEADERS := config.h jot.h pk.h
1111

1212
all: ptrkeys
1313

14+
ptrkeys: VERSION := $(shell git rev-parse HEAD)
1415
ptrkeys: ${HEADERS} ptrkeys.c pk.c
15-
${CC} -o $@ ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} ptrkeys.c pk.c
16+
${CC} -o $@ ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} -DVERSION=\"${VERSION}\" ptrkeys.c pk.c
1617

1718
config.h:
1819
cp config.def.h $@

ptrkeys.1

+12-4
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,24 @@
33
ptrkeys \- mouse keys for X11
44
.SH SYNOPSIS
55
.B ptrkeys
6-
.RB [ \-d ]
6+
.RB [ \-d | \-\-debug ]
7+
.RB [ \-h | \-\-help ]
8+
.RB [ \-\-version ]
79
.SH DESCRIPTION
810
ptrkeys binds the keyboard to pointer movement, scrolling, and mouse button presses on X.
911
.P
1012
See README.md in the source repository for more information.
1113
.SH OPTIONS
1214
.TP
13-
.B \-d
14-
enable debug output
15-
.SH KEY BINDINGS
15+
.B \-d, \-\-debug
16+
Enable debug output.
17+
.TP
18+
.B \-h, \-\-help
19+
Print help.
20+
.TP
21+
.B \-\-version
22+
Print version.
23+
.SH DEFAULT KEY BINDINGS
1624
By default ptrkeys has a handful of "global hotkeys", marked with "(global)" below, that are passively grabbed with X and used to actively grab the keyboard so the rest of the keybindings are active.
1725
.SS Enable/Disable
1826
.TP

ptrkeys.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "pk.h"
88
#include "jot.h"
99

10-
#define USAGE "usage: ptrkeys [-d|--debug] [-h|--help]\n"
10+
#define USAGE "usage: ptrkeys [-d|--debug] [-h|--help] [--version]\n"
1111

1212
static void onsigint();
1313
static void setsighandler();
@@ -45,6 +45,9 @@ parseargs(int argc, char *argv[])
4545
} else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
4646
fprintf(stdout, USAGE);
4747
exit(0);
48+
} else if (!strcmp(argv[i], "--version")) {
49+
fprintf(stdout, VERSION "\n");
50+
exit(0);
4851
} else {
4952
fprintf(stderr, USAGE);
5053
exit(1);

0 commit comments

Comments
 (0)