From 52e70c3802e4e4ceac54bb4d1e4e2870affaff41 Mon Sep 17 00:00:00 2001 From: Axel Wagner Date: Sun, 20 Mar 2011 19:29:30 +0100 Subject: [PATCH] Add Color for focused ws (thx phnom) --- i3bar/doc/i3bar.man | 2 +- i3bar/include/xcb.h | 2 ++ i3bar/src/main.c | 12 +++++++++++- i3bar/src/xcb.c | 13 +++++++++++-- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/i3bar/doc/i3bar.man b/i3bar/doc/i3bar.man index 41a80bfa..44d5e8ac 100644 --- a/i3bar/doc/i3bar.man +++ b/i3bar/doc/i3bar.man @@ -53,7 +53,7 @@ Also, you should disable the internal workspace bar of *i3*(1), when using *i3ba For now this happens with the following command-line-options: -*--color-bar-fg, --color-bar-bg, --color-active-ws-fg, --color-active-ws-bg, --color-inactive-ws-fg, --color-inactive-ws-bg, color-urgent-ws-bg, color-urgent-ws-fg* +*--color-bar-fg, --color-bar-bg, --color-active-ws-fg, --color-active-ws-bg, --color-inactive-ws-fg, --color-inactive-ws-bg, --color-urgent-ws-bg, --color-urgent-ws-fg, --color-focus-ws-fg, --color-focus-ws-bg* For each specified option you need to give a HEX-colorcode. diff --git a/i3bar/include/xcb.h b/i3bar/include/xcb.h index 931e7643..b1732905 100644 --- a/i3bar/include/xcb.h +++ b/i3bar/include/xcb.h @@ -19,6 +19,8 @@ struct xcb_color_strings_t { char *active_ws_bg; char *inactive_ws_fg; char *inactive_ws_bg; + char *focus_ws_bg; + char *focus_ws_fg; char *urgent_ws_bg; char *urgent_ws_fg; }; diff --git a/i3bar/src/main.c b/i3bar/src/main.c index b09a220f..ad8a9993 100644 --- a/i3bar/src/main.c +++ b/i3bar/src/main.c @@ -75,6 +75,8 @@ static void free_colors(struct xcb_color_strings_t *colors) { FREE_COLOR(inactive_ws_bg); FREE_COLOR(urgent_ws_fg); FREE_COLOR(urgent_ws_bg); + FREE_COLOR(focus_ws_fg); + FREE_COLOR(focus_ws_bg); #undef FREE_COLOR } @@ -141,10 +143,12 @@ int main(int argc, char **argv) { { "color-inactive-ws-bg", required_argument, 0, 'F' }, { "color-urgent-ws-bg", required_argument, 0, 'G' }, { "color-urgent-ws-fg", required_argument, 0, 'H' }, + { "color-focus-ws-bg", required_argument, 0, 'I' }, + { "color-focus-ws-fg", required_argument, 0, 'J' }, { NULL, 0, 0, 0} }; - while ((opt = getopt_long(argc, argv, "s:c:d::mf:hvVA:B:C:D:E:F:G:H:", long_opt, &option_index)) != -1) { + while ((opt = getopt_long(argc, argv, "s:c:d::mf:hvVA:B:C:D:E:F:G:H:I:J:", long_opt, &option_index)) != -1) { switch (opt) { case 's': socket_path = expand_path(optarg); @@ -204,6 +208,12 @@ int main(int argc, char **argv) { case 'H': read_color(&colors.urgent_ws_fg); break; + case 'I': + read_color(&colors.focus_ws_bg); + break; + case 'J': + read_color(&colors.focus_ws_fg); + break; default: print_usage(argv[0]); exit(EXIT_SUCCESS); diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index 9cb77f3f..96dbe12e 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -76,6 +76,8 @@ struct xcb_colors_t { uint32_t inactive_ws_bg; uint32_t urgent_ws_bg; uint32_t urgent_ws_fg; + uint32_t focus_ws_bg; + uint32_t focus_ws_fg; }; struct xcb_colors_t colors; @@ -276,6 +278,8 @@ void init_colors(const struct xcb_color_strings_t *new_colors) { PARSE_COLOR(inactive_ws_bg, "240000"); PARSE_COLOR(urgent_ws_fg, "FFFFFF"); PARSE_COLOR(urgent_ws_bg, "002400"); + PARSE_COLOR(focus_ws_fg, "FFFFFF"); + PARSE_COLOR(focus_ws_bg, "480000"); #undef PARSE_COLOR } @@ -939,8 +943,13 @@ void draw_bars() { uint32_t fg_color = colors.inactive_ws_fg; uint32_t bg_color = colors.inactive_ws_bg; if (ws_walk->visible) { - fg_color = colors.active_ws_fg; - bg_color = colors.active_ws_bg; + if (!ws_walk->focused) { + fg_color = colors.active_ws_fg; + bg_color = colors.active_ws_bg; + } else { + fg_color = colors.focus_ws_fg; + bg_color = colors.focus_ws_bg; + } } if (ws_walk->urgent) { DLOG("WS %s is urgent!\n", ws_walk->name);