6464
6565#include <linux/uinput.h>
6666
67+ #ifndef VERSION
68+ #define VERSION "unknown"
69+ #endif
70+
6771#define SOCKET_PATH_LEN 108
6872
6973static 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+
8796enum 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