3 #include "../../kernel/action.h"
9 extern int kparselex();
10 extern int kparselineno;
11 extern FILE *kparsein; /* lexer input */
13 void kparseerror(char *s);
14 static void addbinding(GList *keylist, char *action, char *path, int num);
25 %token <integer> INTEGER
26 %token <string> STRING
28 %token <string> DESKTOP
36 | config fields FIELD '\n' { addbinding($2, $3, NULL, 0); }
37 | config fields FIELD INTEGER '\n' { addbinding($2, $3, NULL, $4); }
38 | config fields FIELD STRING '\n' { addbinding($2, $3, $4, 0); }
42 FIELD { $$ = g_list_append(NULL, $1); }
43 | fields FIELD { $$ = g_list_append($1, $2); }
48 void kparseerror(char *s) {
49 g_warning("Parser error in '%s' on line %d", path, kparselineno);
54 path = g_build_filename(g_get_home_dir(), ".openbox", "keysrc", NULL);
55 if ((kparsein = fopen(path, "r")) == NULL) {
57 path = g_build_filename(RCDIR, "keysrc", NULL);
58 if ((kparsein = fopen(path, "r")) == NULL) {
59 g_warning("No keysrc file found!");
70 static void addbinding(GList *keylist, char *action, char *apath, int num)
74 a = action_from_string(action);
76 /* no move/resize with the keyboard */
77 if (a && (a->func == action_move || a->func == action_resize)) {
82 g_warning("Invalid action '%s' in '%s' on line %d", action, apath,
86 /* these have extra data! */
87 if (a->func == action_execute || a->func == action_restart)
88 a->data.execute.path = apath;
91 if (a->func == action_desktop || a->func == action_send_to_desktop)
92 a->data.desktop.desk = (unsigned) num - 1;
93 if (a->func == action_move_relative_horz ||
94 a->func == action_move_relative_vert ||
95 a->func == action_resize_relative_horz ||
96 a->func == action_resize_relative_vert)
97 a->data.relative.delta = num;
99 if (!kbind(keylist, a)) {
101 g_warning("Unable to add binding in '%s' on line %d", path,