Allow different modifier keys for showing hidden i3bar.

This commit is contained in:
dbp
2011-12-11 21:58:57 -08:00
committed by Michael Stapelberg
parent f88c779457
commit a3081c488a
7 changed files with 152 additions and 7 deletions

View File

@ -59,6 +59,7 @@ EOL (\r?\n)
%x BUFFER_LINE
%x BAR
%x BAR_MODE
%x BAR_MODIFIER
%x BAR_POSITION
%x BAR_COLORS
%x BAR_COLOR
@ -88,7 +89,7 @@ EOL (\r?\n)
}
/* This part of the lexer handles the bar {} blocks */
<BAR,BAR_MODE,BAR_POSITION,BAR_COLORS,BAR_COLOR>[ \t]+ { /* ignore whitespace */ ; }
<BAR,BAR_MODE,BAR_MODIFIER,BAR_POSITION,BAR_COLORS,BAR_COLOR>[ \t]+ { /* ignore whitespace */ ; }
<BAR>"{" { return '{'; }
<BAR>"}" { yy_pop_state(); return '}'; }
<BAR>^[ \t]*#[^\n]* { return TOKCOMMENT; }
@ -98,6 +99,15 @@ EOL (\r?\n)
<BAR>mode { yy_push_state(BAR_MODE); return TOK_BAR_MODE; }
<BAR_MODE>hide { yy_pop_state(); return TOK_BAR_HIDE; }
<BAR_MODE>dock { yy_pop_state(); return TOK_BAR_DOCK; }
<BAR>modifier { yy_push_state(BAR_MODIFIER); return TOK_BAR_MODIFIER; }
<BAR_MODIFIER>control { yy_pop_state(); return TOK_BAR_CONTROL; }
<BAR_MODIFIER>ctrl { yy_pop_state(); return TOK_BAR_CONTROL; }
<BAR_MODIFIER>shift { yy_pop_state(); return TOK_BAR_SHIFT; }
<BAR_MODIFIER>Mod1 { yy_pop_state(); return TOK_BAR_MOD1; }
<BAR_MODIFIER>Mod2 { yy_pop_state(); return TOK_BAR_MOD2; }
<BAR_MODIFIER>Mod3 { yy_pop_state(); return TOK_BAR_MOD3; }
<BAR_MODIFIER>Mod4 { yy_pop_state(); return TOK_BAR_MOD4; }
<BAR_MODIFIER>Mod5 { yy_pop_state(); return TOK_BAR_MOD5; }
<BAR>position { yy_push_state(BAR_POSITION); return TOK_BAR_POSITION; }
<BAR_POSITION>bottom { yy_pop_state(); return TOK_BAR_BOTTOM; }
<BAR_POSITION>top { yy_pop_state(); return TOK_BAR_TOP; }
@ -117,7 +127,7 @@ EOL (\r?\n)
<BAR_COLORS>inactive_workspace { BAR_DOUBLE_COLOR; return TOK_BAR_COLOR_INACTIVE_WORKSPACE; }
<BAR_COLORS>urgent_workspace { BAR_DOUBLE_COLOR; return TOK_BAR_COLOR_URGENT_WORKSPACE; }
<BAR_COLOR>#[0-9a-fA-F]+ { yy_pop_state(); yylval.string = sstrdup(yytext); return HEXCOLOR; }
<BAR,BAR_COLORS,BAR_MODE,BAR_POSITION>[a-zA-Z]+ { yylval.string = sstrdup(yytext); return WORD; }
<BAR,BAR_COLORS,BAR_MODE,BAR_MODIFIER,BAR_POSITION>[a-zA-Z]+ { yylval.string = sstrdup(yytext); return WORD; }

View File

@ -708,6 +708,14 @@ void parse_file(const char *f) {
%token TOK_BAR_MODE "mode (bar)"
%token TOK_BAR_HIDE "hide"
%token TOK_BAR_DOCK "dock"
%token TOK_BAR_MODIFIER "modifier (bar)"
%token TOK_BAR_CONTROL "shift (bar)"
%token TOK_BAR_SHIFT "control (bar)"
%token TOK_BAR_MOD1 "Mod1"
%token TOK_BAR_MOD2 "Mod2"
%token TOK_BAR_MOD3 "Mod3"
%token TOK_BAR_MOD4 "Mod4"
%token TOK_BAR_MOD5 "Mod5"
%token TOK_BAR_POSITION "position"
%token TOK_BAR_BOTTOM "bottom"
%token TOK_BAR_TOP "top"
@ -748,6 +756,7 @@ void parse_file(const char *f) {
%type <number> popup_setting
%type <number> bar_position_position
%type <number> bar_mode_mode
%type <number> bar_modifier_modifier
%type <number> optional_no_startup_id
%type <string> command
%type <string> word_or_number
@ -1042,6 +1051,7 @@ barline:
| bar_tray_output
| bar_position
| bar_mode
| bar_modifier
| bar_font
| bar_workspace_buttons
| bar_verbose
@ -1119,6 +1129,23 @@ bar_mode_mode:
| TOK_BAR_DOCK { $$ = M_DOCK; }
;
bar_modifier:
TOK_BAR_MODIFIER bar_modifier_modifier
{
DLOG("modifier %d\n", $2);
current_bar.modifier = $2;
};
bar_modifier_modifier:
TOK_BAR_CONTROL { $$ = M_CONTROL; }
| TOK_BAR_SHIFT { $$ = M_SHIFT; }
| TOK_BAR_MOD1 { $$ = M_MOD1; }
| TOK_BAR_MOD2 { $$ = M_MOD2; }
| TOK_BAR_MOD3 { $$ = M_MOD3; }
| TOK_BAR_MOD4 { $$ = M_MOD4; }
| TOK_BAR_MOD5 { $$ = M_MOD5; }
;
bar_font:
TOK_BAR_FONT STR
{

View File

@ -589,6 +589,36 @@ IPC_HANDLER(get_bar_config) {
ystr("hide");
else ystr("dock");
ystr("modifier");
switch (config->modifier) {
case M_CONTROL:
ystr("ctrl");
break;
case M_SHIFT:
ystr("shift");
break;
case M_MOD1:
ystr("Mod1");
break;
case M_MOD2:
ystr("Mod2");
break;
case M_MOD3:
ystr("Mod3");
break;
/*
case M_MOD4:
ystr("Mod4");
break;
*/
case M_MOD5:
ystr("Mod5");
break;
default:
ystr("Mod4");
break;
}
ystr("position");
if (config->position == P_BOTTOM)
ystr("bottom");