Skip to content

Commit fe91c1f

Browse files
committed
Add version information in ydotoold
1 parent 372f992 commit fe91c1f

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ else()
1717
set(SD_UNITDIR "lib/systemd/user")
1818
endif()
1919

20+
execute_process(COMMAND git describe --tags --long --always RESULT_VARIABLE RC_GIT_VER OUTPUT_VARIABLE GIT_VERSION)
21+
22+
if (${RC_GIT_VER} EQUAL 0)
23+
string(STRIP ${GIT_VERSION} GIT_VERSION)
24+
message("-- Version: " ${GIT_VERSION})
25+
add_definitions(-DVERSION=\"${GIT_VERSION}\")
26+
endif()
27+
28+
2029

2130
set(SOURCE_FILES_DAEMON Daemon/ydotoold.c)
2231
set(SOURCE_FILES_CLIENT Client/ydotool.c Client/tool_click.c Client/tool_mousemove.c Client/tool_type.c Client/tool_key.c)

Daemon/ydotoold.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464

6565
#include <linux/uinput.h>
6666

67+
#ifndef VERSION
68+
#define VERSION "unknown"
69+
#endif
70+
6771
#define SOCKET_PATH_LEN 108
6872

6973
static char opt_socket_path[SOCKET_PATH_LEN] = "/tmp/.ydotool_socket";
@@ -78,12 +82,17 @@ static void show_help() {
7882
" -p, --socket-path=PATH Custom socket path\n"
7983
" -P, --socket-perm=PERM Socket permission\n"
8084
" -m, --mouse-off Disable mouse (EV_REL)\n"
81-
" -k, --keyboard-off Disable mouse (EV_KEY)\n"
85+
" -k, --keyboard-off Disable keyboard (EV_KEY)\n"
8286
" -T, --touch-on Enable touchscreen (EV_ABS)\n"
8387
" -h, --help Display this help and exit\n"
88+
" -V, --version Show version information\n"
8489
);
8590
}
8691

92+
static void show_version() {
93+
puts(VERSION);
94+
}
95+
8796
enum ydotool_uinput_setup_options {
8897
ENABLE_KEY = (1 << 0),
8998
ENABLE_REL = (1 << 1),
@@ -175,15 +184,18 @@ int main(int argc, char **argv) {
175184

176185
static struct option long_options[] = {
177186
{"help", no_argument, 0, 'h'},
187+
{"version", no_argument, 0, 'V'},
178188
{"socket-perm", required_argument, 0, 'P'},
179189
{"socket-path", required_argument, 0, 'p'},
180190
{"mouse-off", no_argument, 0, 'm'},
191+
{"keyboard-off", no_argument, 0, 'k'},
192+
{"touch-on", no_argument, 0, 'T'},
181193
{0, 0, 0, 0}
182194
};
183195
/* getopt_long stores the option index here. */
184196
int option_index = 0;
185197

186-
c = getopt_long (argc, argv, "hp:P:m",
198+
c = getopt_long (argc, argv, "hVp:P:mkT",
187199
long_options, &option_index);
188200

189201
/* Detect the end of the options. */
@@ -225,6 +237,11 @@ int main(int argc, char **argv) {
225237
exit(0);
226238
break;
227239

240+
case 'V':
241+
show_version();
242+
exit(0);
243+
break;
244+
228245
case '?':
229246
/* getopt_long already printed an error message. */
230247
break;

0 commit comments

Comments
 (0)