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> EXECUTE
29 %token <string> RESTART
30 %token <string> DESKTOP
38 | config fields FIELD '\n' { addbinding($2, $3, NULL, 0); }
39 | config fields DESKTOP INTEGER '\n' { addbinding($2, $3, NULL, $4); }
40 | config fields RESTART '\n' { addbinding($2, $3, NULL, 0); }
41 | config fields EXECUTE STRING '\n' { addbinding($2, $3, $4, 0); }
42 | config fields RESTART STRING '\n' { addbinding($2, $3, $4, 0); }
46 FIELD { $$ = g_list_prepend(NULL, $1); }
47 | fields FIELD { $$ = g_list_prepend($1, $2); }
52 void kparseerror(char *s) {
53 g_warning("Parser error in '%s' on line %d", path, kparselineno);
58 path = g_build_filename(g_get_home_dir(), ".openbox", "keysrc", NULL);
59 if ((kparsein = fopen(path, "r")) == NULL) {
61 path = g_build_filename(RCDIR, "keysrc", NULL);
62 if ((kparsein = fopen(path, "r")) == NULL) {
63 g_warning("No keysrc file found!");
74 static void addbinding(GList *keylist, char *action, char *apath, int num)
78 a = action_from_string(action);
80 /* no move/resize with the keyboard */
81 if (a && (a->func == action_move || a->func == action_resize)) {
86 g_warning("Invalid action '%s' in '%s' on line %d", action, apath,
90 /* these have extra data! */
91 if (a->func == action_execute || a->func == action_restart)
92 a->data.execute.path = apath;
93 if (a->func == action_desktop)
94 a->data.desktop.desk = (unsigned) num + 1;
96 if (!kbind(keylist, a)) {
98 g_warning("Unable to add binding in '%s' on line %d", path,