From f23d675de9ca445a07e60d52cf3d9df04a444c51 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Thu, 24 Nov 2011 21:53:29 +0100 Subject: [PATCH] Implement new "i3bar_command" option for bar. This allows you to specify an alternate path to the i3bar binary. The userguide docu is included. --- docs/userguide | 22 ++++++++++++++++++++++ include/config.h | 5 +++++ src/cfgparse.l | 1 + src/cfgparse.y | 11 +++++++++++ src/config.c | 1 + src/main.c | 5 +++-- 6 files changed, 43 insertions(+), 2 deletions(-) diff --git a/docs/userguide b/docs/userguide index 79c97b12..26c12b77 100644 --- a/docs/userguide +++ b/docs/userguide @@ -796,6 +796,28 @@ bar { } --------------------------- +=== i3bar command + +By default i3 will just pass +i3bar+ and let your shell handle the execution, +searching your +$PATH+ for a correct version. +If you have a different +i3bar+ somewhere or the binary is not in your +$PATH+ you can +tell i3 what to execute. + +The specified command will be passed to +sh -c+, so you can use globbing and +have to have correct quoting etc. + +*Syntax*: +---------------------- +i3bar_command command +---------------------- + +*Example*: +------------------------------------------------- +bar { + i3bar_command /home/user/bin/i3bar +} +------------------------------------------------- + === Statusline command i3bar can run a program and display every line of its +stdout+ output on the diff --git a/include/config.h b/include/config.h index b4128caf..ea1885cc 100644 --- a/include/config.h +++ b/include/config.h @@ -201,6 +201,11 @@ struct Barconfig { /** Bar position (bottom by default). */ enum { P_BOTTOM = 0, P_TOP = 1 } position; + /** Command that should be run to execute i3bar, give a full path if i3bar is not + * in your $PATH. + * By default just 'i3bar' is executed. */ + char *i3bar_command; + /** Command that should be run to get a statusline, for example 'i3status'. * Will be passed to the shell. */ char *status_command; diff --git a/src/cfgparse.l b/src/cfgparse.l index 1566e24f..673724a8 100644 --- a/src/cfgparse.l +++ b/src/cfgparse.l @@ -102,6 +102,7 @@ EOL (\r?\n) bottom { yy_pop_state(); return TOK_BAR_BOTTOM; } top { yy_pop_state(); return TOK_BAR_TOP; } status_command { WS_STRING; return TOK_BAR_STATUS_COMMAND; } +i3bar_command { WS_STRING; return TOK_BAR_I3BAR_COMMAND; } font { WS_STRING; return TOK_BAR_FONT; } workspace_buttons { return TOK_BAR_WORKSPACE_BUTTONS; } verbose { return TOK_BAR_VERBOSE; } diff --git a/src/cfgparse.y b/src/cfgparse.y index 0d2c6977..cebd8587 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -705,6 +705,7 @@ void parse_file(const char *f) { %token TOK_BAR_BOTTOM "bottom" %token TOK_BAR_TOP "top" %token TOK_BAR_STATUS_COMMAND "status_command" +%token TOK_BAR_I3BAR_COMMAND "i3bar_command" %token TOK_BAR_FONT "font (bar)" %token TOK_BAR_WORKSPACE_BUTTONS "workspace_buttons" %token TOK_BAR_VERBOSE "verbose" @@ -1029,6 +1030,7 @@ barlines: barline: comment | bar_status_command + | bar_i3bar_command | bar_output | bar_tray_output | bar_position @@ -1055,6 +1057,15 @@ bar_status_command: } ; +bar_i3bar_command: + TOK_BAR_I3BAR_COMMAND STR + { + DLOG("should add i3bar_command %s\n", $2); + FREE(current_bar.i3bar_command); + current_bar.i3bar_command = $2; + } + ; + bar_output: TOK_BAR_OUTPUT STR { diff --git a/src/config.c b/src/config.c index 673f297e..7b0b34e3 100644 --- a/src/config.c +++ b/src/config.c @@ -299,6 +299,7 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath, FREE(barconfig->tray_output); FREE(barconfig->socket_path); FREE(barconfig->status_command); + FREE(barconfig->i3bar_command); FREE(barconfig->font); FREE(barconfig->colors.background); FREE(barconfig->colors.statusline); diff --git a/src/main.c b/src/main.c index 7a7c20ac..38412d53 100644 --- a/src/main.c +++ b/src/main.c @@ -689,8 +689,9 @@ int main(int argc, char *argv[]) { Barconfig *barconfig; TAILQ_FOREACH(barconfig, &barconfigs, configs) { char *command = NULL; - sasprintf(&command, "i3bar --bar_id=%s --socket=\"%s\"", - barconfig->id, current_socketpath); + sasprintf(&command, "%s --bar_id=%s --socket=\"%s\"", + barconfig->i3bar_command ? barconfig->i3bar_command : "i3bar", + barconfig->id, current_socketpath); LOG("Starting bar process: %s\n", command); start_application(command, true); free(command); -- 2.39.5