Allow "modifier none" in i3bar to disable the modifier.
This allows "modifier none" (and "modifier off") for the bar config in order to disable the modifier key altogether. This is useful for users who use a different approach to hiding / showing the bar, e.g., a custom keybind that involved multiple keys or scripts. fixes #2208
This commit is contained in:
parent
e2d1f0f567
commit
018922dcc4
|
@ -1238,7 +1238,7 @@ the windows key). The default value for the hidden_state is hide.
|
||||||
-------------------------
|
-------------------------
|
||||||
mode dock|hide|invisible
|
mode dock|hide|invisible
|
||||||
hidden_state hide|show
|
hidden_state hide|show
|
||||||
modifier <Modifier>
|
modifier <Modifier>|none
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
*Example*:
|
*Example*:
|
||||||
|
@ -1250,7 +1250,8 @@ bar {
|
||||||
}
|
}
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
Available modifiers are Mod1-Mod5, Shift, Control (see +xmodmap(1)+).
|
Available modifiers are Mod1-Mod5, Shift, Control (see +xmodmap(1)+). You can
|
||||||
|
also use "none" if you don't want any modifier to trigger this behavior.
|
||||||
|
|
||||||
=== Mouse button commands
|
=== Mouse button commands
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,11 @@ static int config_string_cb(void *params_, const unsigned char *val, size_t _len
|
||||||
|
|
||||||
if (!strcmp(cur_key, "modifier")) {
|
if (!strcmp(cur_key, "modifier")) {
|
||||||
DLOG("modifier = %.*s\n", len, val);
|
DLOG("modifier = %.*s\n", len, val);
|
||||||
|
if (len == 4 && !strncmp((const char *)val, "none", strlen("none"))) {
|
||||||
|
config.modifier = XCB_NONE;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (len == 5 && !strncmp((const char *)val, "shift", strlen("shift"))) {
|
if (len == 5 && !strncmp((const char *)val, "shift", strlen("shift"))) {
|
||||||
config.modifier = ShiftMask;
|
config.modifier = ShiftMask;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -140,16 +145,12 @@ static int config_string_cb(void *params_, const unsigned char *val, size_t _len
|
||||||
case '3':
|
case '3':
|
||||||
config.modifier = Mod3Mask;
|
config.modifier = Mod3Mask;
|
||||||
return 1;
|
return 1;
|
||||||
/*
|
|
||||||
case '4':
|
|
||||||
config.modifier = Mod4Mask;
|
|
||||||
return 1;
|
|
||||||
*/
|
|
||||||
case '5':
|
case '5':
|
||||||
config.modifier = Mod5Mask;
|
config.modifier = Mod5Mask;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.modifier = Mod4Mask;
|
config.modifier = Mod4Mask;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1094,7 +1094,7 @@ void xcb_chk_cb(struct ev_loop *loop, ev_check *watcher, int revents) {
|
||||||
DLOG("received an xkb event\n");
|
DLOG("received an xkb event\n");
|
||||||
|
|
||||||
xcb_xkb_state_notify_event_t *state = (xcb_xkb_state_notify_event_t *)event;
|
xcb_xkb_state_notify_event_t *state = (xcb_xkb_state_notify_event_t *)event;
|
||||||
if (state->xkbType == XCB_XKB_STATE_NOTIFY) {
|
if (state->xkbType == XCB_XKB_STATE_NOTIFY && config.modifier != XCB_NONE) {
|
||||||
int modstate = state->mods & config.modifier;
|
int modstate = state->mods & config.modifier;
|
||||||
|
|
||||||
#define DLOGMOD(modmask, status) \
|
#define DLOGMOD(modmask, status) \
|
||||||
|
|
|
@ -453,7 +453,7 @@ state BAR_ID:
|
||||||
-> call cfg_bar_id($bar_id); BAR
|
-> call cfg_bar_id($bar_id); BAR
|
||||||
|
|
||||||
state BAR_MODIFIER:
|
state BAR_MODIFIER:
|
||||||
modifier = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Control', 'Ctrl', 'Shift'
|
modifier = 'Mod1', 'Mod2', 'Mod3', 'Mod4', 'Mod5', 'Control', 'Ctrl', 'Shift', 'none', 'off'
|
||||||
-> call cfg_bar_modifier($modifier); BAR
|
-> call cfg_bar_modifier($modifier); BAR
|
||||||
|
|
||||||
state BAR_WHEEL_UP_CMD:
|
state BAR_WHEEL_UP_CMD:
|
||||||
|
|
|
@ -446,6 +446,9 @@ CFGFUN(bar_modifier, const char *modifier) {
|
||||||
current_bar->modifier = M_CONTROL;
|
current_bar->modifier = M_CONTROL;
|
||||||
else if (strcmp(modifier, "Shift") == 0)
|
else if (strcmp(modifier, "Shift") == 0)
|
||||||
current_bar->modifier = M_SHIFT;
|
current_bar->modifier = M_SHIFT;
|
||||||
|
else if (strcmp(modifier, "none") == 0 ||
|
||||||
|
strcmp(modifier, "off") == 0)
|
||||||
|
current_bar->modifier = M_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bar_configure_binding(const char *button, const char *command) {
|
static void bar_configure_binding(const char *button, const char *command) {
|
||||||
|
@ -575,6 +578,7 @@ CFGFUN(bar_start) {
|
||||||
TAILQ_INIT(&(current_bar->bar_bindings));
|
TAILQ_INIT(&(current_bar->bar_bindings));
|
||||||
TAILQ_INIT(&(current_bar->tray_outputs));
|
TAILQ_INIT(&(current_bar->tray_outputs));
|
||||||
current_bar->tray_padding = 2;
|
current_bar->tray_padding = 2;
|
||||||
|
current_bar->modifier = M_MOD4;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFGFUN(bar_finish) {
|
CFGFUN(bar_finish) {
|
||||||
|
|
|
@ -611,6 +611,9 @@ static void dump_bar_config(yajl_gen gen, Barconfig *config) {
|
||||||
|
|
||||||
ystr("modifier");
|
ystr("modifier");
|
||||||
switch (config->modifier) {
|
switch (config->modifier) {
|
||||||
|
case M_NONE:
|
||||||
|
ystr("none");
|
||||||
|
break;
|
||||||
case M_CONTROL:
|
case M_CONTROL:
|
||||||
ystr("ctrl");
|
ystr("ctrl");
|
||||||
break;
|
break;
|
||||||
|
@ -626,11 +629,6 @@ static void dump_bar_config(yajl_gen gen, Barconfig *config) {
|
||||||
case M_MOD3:
|
case M_MOD3:
|
||||||
ystr("Mod3");
|
ystr("Mod3");
|
||||||
break;
|
break;
|
||||||
/*
|
|
||||||
case M_MOD4:
|
|
||||||
ystr("Mod4");
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case M_MOD5:
|
case M_MOD5:
|
||||||
ystr("Mod5");
|
ystr("Mod5");
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue