Available modifiers are Mod1-Mod5, Shift, Control (see +xmodmap(1)+).
+=== Mouse button commands
+
+Specifies a command to run when a button was pressed on i3bar to override the
+default behavior. Currently only the mouse wheel buttons are supported. This is
+useful for disabling the scroll wheel action or running scripts that implement
+custom behavior for these buttons.
+
+*Syntax*:
+---------------------
+wheel_up_cmd <command>
+wheel_down_cmd <command>
+---------------------
+
+*Example*:
+---------------------
+bar {
+ wheel_up_cmd nop
+ wheel_down_cmd exec ~/.i3/scripts/custom_wheel_down
+}
+---------------------
+
=== Bar ID
Specifies the bar ID for the configured bar instance. If this option is missing,
typedef struct config_t {
int modifier;
+ char *wheel_up_cmd;
+ char *wheel_down_cmd;
position_t position;
int verbose;
struct xcb_color_strings_t colors;
return 1;
}
+ if (!strcmp(cur_key, "wheel_up_cmd")) {
+ DLOG("wheel_up_cmd = %.*s\n", len, val);
+ FREE(config.wheel_up_cmd);
+ sasprintf(&config.wheel_up_cmd, "%.*s", len, val);
+ return 1;
+ }
+
+ if (!strcmp(cur_key, "wheel_down_cmd")) {
+ DLOG("wheel_down_cmd = %.*s\n", len, val);
+ FREE(config.wheel_down_cmd);
+ sasprintf(&config.wheel_down_cmd, "%.*s", len, val);
+ return 1;
+ }
+
if (!strcmp(cur_key, "position")) {
DLOG("position = %.*s\n", len, val);
config.position = (len == 3 && !strncmp((const char *)val, "top", strlen("top")) ? POS_TOP : POS_BOT);
* If there is no more workspace, don’t even send the workspace
* command, otherwise (with workspace auto_back_and_forth) we’d end
* up on the wrong workspace. */
+
+ /* If `wheel_up_cmd [COMMAND]` was specified, it should override
+ * the default behavior */
+ if (config.wheel_up_cmd) {
+ i3_send_msg(I3_IPC_MESSAGE_TYPE_COMMAND, config.wheel_up_cmd);
+ return;
+ }
+
if (cur_ws == TAILQ_FIRST(walk->workspaces))
return;
* If there is no more workspace, don’t even send the workspace
* command, otherwise (with workspace auto_back_and_forth) we’d end
* up on the wrong workspace. */
+
+ /* if `wheel_down_cmd [COMMAND]` was specified, it should override
+ * the default behavior */
+ if (config.wheel_down_cmd) {
+ i3_send_msg(I3_IPC_MESSAGE_TYPE_COMMAND, config.wheel_down_cmd);
+ return;
+ }
+
if (cur_ws == TAILQ_LAST(walk->workspaces, ws_head))
return;
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;
+
/** Bar position (bottom by default). */
enum { P_BOTTOM = 0,
P_TOP = 1 } position;
CFGFUN(bar_output, const char *output);
CFGFUN(bar_verbose, const char *verbose);
CFGFUN(bar_modifier, const char *modifier);
+CFGFUN(bar_wheel_up_cmd, const char *command);
+CFGFUN(bar_wheel_down_cmd, const char *command);
CFGFUN(bar_position, const char *position);
CFGFUN(bar_i3bar_command, const char *i3bar_command);
CFGFUN(bar_color, const char *colorclass, const char *border, const char *background, const char *text);
'hidden_state' -> BAR_HIDDEN_STATE
'id' -> BAR_ID
'modifier' -> BAR_MODIFIER
+ 'wheel_up_cmd' -> BAR_WHEEL_UP_CMD
+ 'wheel_down_cmd' -> BAR_WHEEL_DOWN_CMD
'position' -> BAR_POSITION
'output' -> BAR_OUTPUT
'tray_output' -> BAR_TRAY_OUTPUT
modifier = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Control', 'Ctrl', 'Shift'
-> call cfg_bar_modifier($modifier); BAR
+state BAR_WHEEL_UP_CMD:
+ command = string
+ -> call cfg_bar_wheel_up_cmd($command); BAR
+
+state BAR_WHEEL_DOWN_CMD:
+ command = string
+ -> call cfg_bar_wheel_down_cmd($command); BAR
+
state BAR_POSITION:
position = 'top', 'bottom'
-> call cfg_bar_position($position); BAR
current_bar.modifier = M_SHIFT;
}
+CFGFUN(bar_wheel_up_cmd, const char *command) {
+ FREE(current_bar.wheel_up_cmd);
+ current_bar.wheel_up_cmd = sstrdup(command);
+}
+
+CFGFUN(bar_wheel_down_cmd, const char *command) {
+ FREE(current_bar.wheel_down_cmd);
+ current_bar.wheel_down_cmd = sstrdup(command);
+}
+
CFGFUN(bar_position, const char *position) {
current_bar.position = (strcmp(position, "top") == 0 ? P_TOP : P_BOTTOM);
}
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);
+ }
+
ystr("position");
if (config->position == P_BOTTOM)
ystr("bottom");
$expected = <<'EOT';
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', 'position', 'output', 'tray_output', 'font', 'binding_mode_indicator', 'workspace_buttons', 'strip_workspace_numbers', 'verbose', 'colors', '}'
+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', 'position', 'output', 'tray_output', 'font', 'binding_mode_indicator', 'workspace_buttons', 'strip_workspace_numbers', 'verbose', 'colors', '}'
ERROR: CONFIG: (in file <stdin>)
ERROR: CONFIG: Line 1: bar {
ERROR: CONFIG: Line 2: output LVDS-1