added -v argument

verbose option: now hkd doesn't default to printing pressed keys basically
acting as a keylogger but now requires -v to do so.
xkbcommon
Alessandro Mauri 4 years ago
parent 3ffa960ae7
commit ea6f548399
  1. 24
      hkd.c

24
hkd.c

@ -210,7 +210,7 @@ void hotkey_list_add (struct hotkey_list_e *, struct key_buffer *, char *, int);
void hotkey_list_destroy (struct hotkey_list_e *); void hotkey_list_destroy (struct hotkey_list_e *);
// TODO: use getopts() to parse command line options // TODO: use getopts() to parse command line options
int main (void) int main (int argc, char *argv[])
{ {
/* Handle SIGINT */ /* Handle SIGINT */
dead = 0; dead = 0;
@ -219,6 +219,18 @@ int main (void)
action.sa_handler = int_handler; action.sa_handler = int_handler;
sigaction(SIGINT, &action, NULL); sigaction(SIGINT, &action, NULL);
/* Verbose flag */
int vflag = 0;
int opc;
while ((opc = getopt(argc, argv, "v")) != -1) {
switch (opc) {
case 'v':
vflag = 1;
break;
}
}
int fd_num = 0; int fd_num = 0;
int *fds = NULL; int *fds = NULL;
update_descriptors_list(&fds, &fd_num); update_descriptors_list(&fds, &fd_num);
@ -289,10 +301,12 @@ int main (void)
struct key_buffer comb1 = {{KEY_LEFTALT, KEY_S}, 2}; struct key_buffer comb1 = {{KEY_LEFTALT, KEY_S}, 2};
if (pb.size > prev_size) { if (pb.size > prev_size) {
printf("Pressed keys: "); if (vflag) {
for (unsigned int i = 0; i < pb.size; i++) printf("Pressed keys: ");
printf("%d ", pb.buf[i]); for (unsigned int i = 0; i < pb.size; i++)
putchar('\n'); printf("%d ", pb.buf[i]);
putchar('\n');
}
if (key_buffer_compare(&pb, &comb1)) if (key_buffer_compare(&pb, &comb1))
exec_command("ls -l [a-z]*"); exec_command("ls -l [a-z]*");

Loading…
Cancel
Save