M_MOD5 = 7
} modifier;
- /** Command that should be run when mouse wheel up button is pressed over
- * i3bar to override the default behavior. */
- char *wheel_up_cmd;
-
- /** Command that should be run when mouse wheel down button is pressed over
- * i3bar to override the default behavior. */
- char *wheel_down_cmd;
+ TAILQ_HEAD(mouse_commands_head, Mousecommand) mouse_commands;
/** Bar position (bottom by default). */
enum { P_BOTTOM = 0,
TAILQ_ENTRY(Barconfig) configs;
};
+/**
+ * Defines a mouse command to be executed instead of the default behavior when
+ * clicking on the non-statusline part of i3bar.
+ *
+ */
+struct Mousecommand {
+ /** The button for this command (e.g., "button1") */
+ char *button;
+
+ /** The command which is to be executed for this button. */
+ char *command;
+
+ TAILQ_ENTRY(Mousecommand) commands;
+};
+
/**
* Finds the configuration file to use (either the one specified by
* override_configpath), the user’s one or the system default) and calls
}
static void bar_configure_mouse_command(const char *button, const char *command) {
+ if (strncasecmp(button, "button", sizeof("button") - 1) != 0) {
+ ELOG("unknown button \"%s\" for mouse command, ignoring.\n", button);
+ return;
+ }
+
+ struct Mousecommand *current;
+ TAILQ_FOREACH(current, &(current_bar.mouse_commands), commands) {
+ if (strcasecmp(current->button, button) == 0) {
+ ELOG("command for button %s was already specified, ignoring.\n", button);
+ return;
+ }
+ }
+
+ struct Mousecommand *new_command = scalloc(sizeof(struct Mousecommand));
+ new_command->button = sstrdup(button);
+ new_command->command = sstrdup(command);
+ TAILQ_INSERT_TAIL(&(current_bar.mouse_commands), new_command, commands);
}
CFGFUN(bar_wheel_up_cmd, const char *command) {
y(map_close);
}
+static void dump_mouse_commands(yajl_gen gen, Barconfig *config) {
+ ystr("mouse_commands");
+ y(map_open);
+
+ struct Mousecommand *current;
+ TAILQ_FOREACH(current, &(config->mouse_commands), commands) {
+ ystr(current->button);
+ ystr(current->command);
+ }
+
+ y(map_close);
+}
+
static void dump_bar_config(yajl_gen gen, Barconfig *config) {
y(map_open);
break;
}
- if (config->wheel_up_cmd) {
- ystr("wheel_up_cmd");
- ystr(config->wheel_up_cmd);
- }
-
- if (config->wheel_down_cmd) {
- ystr("wheel_down_cmd");
- ystr(config->wheel_down_cmd);
- }
+ dump_mouse_commands(gen, config);
ystr("position");
if (config->position == P_BOTTOM)
EOT
$expected = <<'EOT';
+cfg_bar_start()
cfg_bar_output(LVDS-1)
ERROR: CONFIG: Expected one of these tokens: <end>, '#', 'set', 'i3bar_command', 'status_command', 'socket_path', 'mode', 'hidden_state', 'id', 'modifier', 'wheel_up_cmd', 'wheel_down_cmd', 'bindsym', 'position', 'output', 'tray_output', 'font', 'separator_symbol', 'binding_mode_indicator', 'workspace_buttons', 'strip_workspace_numbers', 'verbose', 'colors', '}'
ERROR: CONFIG: (in file <stdin>)