aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalvin <calvin@bastille>2014-02-11 16:16:40 -0500
committerCalvin <calvin@bastille>2014-02-11 16:16:40 -0500
commit03b558185d8e7d574fb1abfe8c979260335747e7 (patch)
tree064dc930d092e179ea2a17dbdb9bc7dd735b2218
parentff6a5ba20186c0e7a0fda27163cd95aa910120eb (diff)
its alive
-rw-r--r--Makefile2
-rw-r--r--example_rc6
-rw-r--r--hotkey.c15
3 files changed, 14 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 7684be2..4fcde41 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ CC =gcc
CFLAGS = -O3 -s -mtune=native -Wextra -Wall
CLIBS = -lX11
-hotkey: hotkey.c keys.h
+hotkey: hotkey.c
$(CC) hotkey.c -o hotkey $(CFLAGS) $(CLIBS)
clean:
diff --git a/example_rc b/example_rc
index 804cf8c..d60c895 100644
--- a/example_rc
+++ b/example_rc
@@ -1,3 +1,3 @@
-control+P dmenu_run &
-control+mod1+G xterm &
-mod1+G xterm &
+control+p dmenu_run &
+control+mod1+g xterm -e mocp &
+mod1+g xterm &
diff --git a/hotkey.c b/hotkey.c
index c87c293..d00062d 100644
--- a/hotkey.c
+++ b/hotkey.c
@@ -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);
}