-static void check_for_duplicate_bindings(struct context *context) {
- Binding *bind, *current;
- TAILQ_FOREACH(current, bindings, bindings) {
- TAILQ_FOREACH(bind, bindings, bindings) {
- /* Abort when we reach the current keybinding, only check the
- * bindings before */
- if (bind == current)
- break;
-
- /* Check if one is using keysym while the other is using bindsym.
- * If so, skip. */
- /* XXX: It should be checked at a later place (when translating the
- * keysym to keycodes) if there are any duplicates */
- if ((bind->symbol == NULL && current->symbol != NULL) ||
- (bind->symbol != NULL && current->symbol == NULL))
- continue;
-
- /* If bind is NULL, current has to be NULL, too (see above).
- * If the keycodes differ, it can't be a duplicate. */
- if (bind->symbol != NULL &&
- strcasecmp(bind->symbol, current->symbol) != 0)
- continue;
-
- /* Check if the keycodes or modifiers are different. If so, they
- * can't be duplicate */
- if (bind->keycode != current->keycode ||
- bind->mods != current->mods ||
- bind->release != current->release)
- continue;
-
- context->has_errors = true;
- if (current->keycode != 0) {
- ELOG("Duplicate keybinding in config file:\n modmask %d with keycode %d, command \"%s\"\n",
- current->mods, current->keycode, current->command);
- } else {
- ELOG("Duplicate keybinding in config file:\n modmask %d with keysym %s, command \"%s\"\n",
- current->mods, current->symbol, current->command);
- }
- }
- }
-}
-
-/*
- * Starts an i3-nagbar process which alerts the user that his configuration
- * file contains one or more errors. Also offers two buttons: One to launch an
- * $EDITOR on the config file and another one to launch a $PAGER on the error
- * logfile.
- *
- */
-static void start_configerror_nagbar(const char *config_path) {
- if (only_check_config)
- return;
-
- fprintf(stderr, "Starting i3-nagbar due to configuration errors\n");
-
- /* We need to create a custom script containing our actual command
- * since not every terminal emulator which is contained in
- * i3-sensible-terminal supports -e with multiple arguments (and not
- * all of them support -e with one quoted argument either).
- *
- * NB: The paths need to be unique, that is, don’t assume users close
- * their nagbars at any point in time (and they still need to work).
- * */
- edit_script_path = get_process_filename("nagbar-cfgerror-edit");
- pager_script_path = get_process_filename("nagbar-cfgerror-pager");
-
- configerror_pid = fork();
- if (configerror_pid == -1) {
- warn("Could not fork()");
- return;
- }
-
- /* child */
- if (configerror_pid == 0) {
- char *edit_command, *pager_command;
- sasprintf(&edit_command, "i3-sensible-editor \"%s\" && i3-msg reload\n", config_path);
- sasprintf(&pager_command, "i3-sensible-pager \"%s\"\n", errorfilename);
- if (!write_nagbar_script(edit_script_path, edit_command) ||
- !write_nagbar_script(pager_script_path, pager_command))
- return;
-
- char *editaction,
- *pageraction;
- sasprintf(&editaction, "i3-sensible-terminal -e \"%s\"", edit_script_path);
- sasprintf(&pageraction, "i3-sensible-terminal -e \"%s\"", pager_script_path);
- char *argv[] = {
- NULL, /* will be replaced by the executable path */
- "-t",
- (context->has_errors ? "error" : "warning"),
- "-m",
- (context->has_errors ?
- "You have an error in your i3 config file!" :
- "Your config is outdated. Please fix the warnings to make sure everything works."),
- "-b",
- "edit config",
- editaction,
- (errorfilename ? "-b" : NULL),
- (context->has_errors ? "show errors" : "show warnings"),
- pageraction,
- NULL
- };
- exec_i3_utility("i3-nagbar", argv);
- }
-
- /* parent */
- /* install a child watcher */
- ev_child *child = smalloc(sizeof(ev_child));
- ev_child_init(child, &nagbar_exited, configerror_pid, 0);
- ev_child_start(main_loop, child);
-
-/* We need ev >= 4 for the following code. Since it is not *that* important (it
- * only makes sure that there are no i3-nagbar instances left behind) we still
- * support old systems with libev 3. */
-#if EV_VERSION_MAJOR >= 4
- /* install a cleanup watcher (will be called when i3 exits and i3-nagbar is
- * still running) */
- ev_cleanup *cleanup = smalloc(sizeof(ev_cleanup));
- ev_cleanup_init(cleanup, nagbar_cleanup);
- ev_cleanup_start(main_loop, cleanup);
-#endif
-}
-
-
-
-void parse_file(const char *f) {