typedef struct config_t {
int hide_on_modifier;
+ int modifier;
position_t position;
int verbose;
struct xcb_color_strings_t colors;
#include <yajl/yajl_parse.h>
#include <yajl/yajl_version.h>
+#include <X11/Xlib.h>
+
#include "common.h"
static char *cur_key;
return 1;
}
+ if (!strcmp(cur_key, "modifier")) {
+ DLOG("modifier = %.*s\n", len, val);
+ if (len == 5 && !strncmp((const char*)val, "shift", strlen("shift"))) {
+ config.modifier = ShiftMask;
+ return 1;
+ }
+ if (len == 4 && !strncmp((const char*)val, "ctrl", strlen("ctrl"))) {
+ config.modifier = ControlMask;
+ return 1;
+ }
+ if (len == 4 && !strncmp((const char*)val, "Mod", strlen("Mod"))) {
+ switch (val[3]) {
+ case '1':
+ config.modifier = Mod1Mask;
+ return 1;
+ case '2':
+ config.modifier = Mod2Mask;
+ return 1;
+ case '3':
+ config.modifier = Mod3Mask;
+ return 1;
+ /*
+ case '4':
+ config.modifier = Mod4Mask;
+ return 1;
+ */
+ case '5':
+ config.modifier = Mod5Mask;
+ return 1;
+ }
+ }
+ config.modifier = Mod4Mask;
+ 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);
}
unsigned int mods = ev.state.mods;
- modstate = mods & Mod4Mask;
+ modstate = mods & config.modifier;
}
+#define DLOGMOD(modmask, status, barfunc) \
+ do { \
+ switch (modmask) { \
+ case ShiftMask: \
+ DLOG("ShiftMask got " #status "!\n"); \
+ break; \
+ case ControlMask: \
+ DLOG("ControlMask got " #status "!\n"); \
+ break; \
+ case Mod1Mask: \
+ DLOG("Mod1Mask got " #status "!\n"); \
+ break; \
+ case Mod2Mask: \
+ DLOG("Mod2Mask got " #status "!\n"); \
+ break; \
+ case Mod3Mask: \
+ DLOG("Mod3Mask got " #status "!\n"); \
+ break; \
+ case Mod4Mask: \
+ DLOG("Mod4Mask got " #status "!\n"); \
+ break; \
+ case Mod5Mask: \
+ DLOG("Mod5Mask got " #status "!\n"); \
+ break; \
+ } \
+ barfunc(); \
+ } while (0)
+
if (modstate != mod_pressed) {
if (modstate == 0) {
- DLOG("Mod4 got released!\n");
- hide_bars();
+ DLOGMOD(config.modifier, released, hide_bars);
} else {
- DLOG("Mod4 got pressed!\n");
- unhide_bars();
+ DLOGMOD(config.modifier, pressed, unhide_bars);
}
mod_pressed = modstate;
}
+
+#undef DLOGMOD
}
/*
/** Bar display mode (hide unless modifier is pressed or show in dock mode) */
enum { M_DOCK = 0, M_HIDE = 1 } mode;
+ /** Bar modifier (to show bar when in hide mode). */
+ enum {
+ M_NONE = 0,
+ M_CONTROL = 1,
+ M_SHIFT = 2,
+ M_MOD1 = 3,
+ M_MOD2 = 4,
+ M_MOD3 = 5,
+ M_MOD4 = 6,
+ M_MOD5 = 7
+ } modifier;
+
/** Bar position (bottom by default). */
enum { P_BOTTOM = 0, P_TOP = 1 } position;
%x BUFFER_LINE
%x BAR
%x BAR_MODE
+%x BAR_MODIFIER
%x BAR_POSITION
%x BAR_COLORS
%x BAR_COLOR
}
/* 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; }
<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; }
<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; }
%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"
%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
| bar_tray_output
| bar_position
| bar_mode
+ | bar_modifier
| bar_font
| bar_workspace_buttons
| bar_verbose
| 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
{
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");