diff options
Diffstat (limited to 'hotkey.c')
-rw-r--r-- | hotkey.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -18,11 +18,13 @@ typedef struct Key { struct Key * parse_key(char *shortcut, char *command) { Key *key = malloc(sizeof(key)); + if(key == NULL) { + fprintf(stderr, "could not allocate keys\n"); + exit(EXIT_FAILURE); + } key->command = command; key->mod = 0; - - printf("%s\n", key->command); size_t i = 0; char *token; @@ -65,6 +67,10 @@ struct Key * parse_key(char *shortcut, char *command) { mask = Mod3Mask; else if(strcmp(tokens[i], "mod4") == 0) mask = Mod4Mask; + else + return NULL; + + if(mask) { key->mod = key->mod | mask ; mod_set = 1; @@ -94,7 +100,7 @@ struct Key **load_hotkeys(FILE *fh, size_t *key_len) { struct Key **keys = malloc(sizeof(struct Key **)); if(keys == NULL) { - printf("could not allocate keys\n"); + fprintf(stderr, "could not allocate keys\n"); return NULL; } @@ -122,7 +128,7 @@ struct Key **load_hotkeys(FILE *fh, size_t *key_len) { realloc_size++; if(keys == NULL) { - printf("could not realloc keys\n"); + fprintf(stderr, "could not realloc keys\n"); exit(EXIT_FAILURE); } } @@ -199,7 +205,6 @@ int main(int argc, char **argv) { } for(i = 0; i < len; i++) { - printf("%d\n", hotkeys[i]->mod); XGrabKey(dpy, XKeysymToKeycode(dpy,hotkeys[i]->keysym), hotkeys[i]->mod, root, False, GrabModeAsync, GrabModeAsync); } |