Merge pull request #359 from mikkeloscar/i3bar-command

Add bar option: swaybar_command <command>
This commit is contained in:
Drew DeVault 2015-12-18 18:19:59 -05:00
commit b9f14cee41
3 changed files with 21 additions and 0 deletions

View file

@ -92,6 +92,7 @@ struct bar_config {
enum desktop_shell_panel_position position; enum desktop_shell_panel_position position;
list_t *bindings; list_t *bindings;
char *status_command; char *status_command;
char *swaybar_command;
char *font; char *font;
int height; // -1 not defined int height; // -1 not defined
int tray_padding; int tray_padding;

View file

@ -79,6 +79,7 @@ static sway_cmd bar_cmd_position;
static sway_cmd bar_cmd_separator_symbol; static sway_cmd bar_cmd_separator_symbol;
static sway_cmd bar_cmd_status_command; static sway_cmd bar_cmd_status_command;
static sway_cmd bar_cmd_strip_workspace_numbers; static sway_cmd bar_cmd_strip_workspace_numbers;
static sway_cmd bar_cmd_swaybar_command;
static sway_cmd bar_cmd_tray_output; static sway_cmd bar_cmd_tray_output;
static sway_cmd bar_cmd_tray_padding; static sway_cmd bar_cmd_tray_padding;
static sway_cmd bar_cmd_workspace_buttons; static sway_cmd bar_cmd_workspace_buttons;
@ -1918,6 +1919,23 @@ static struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv
return cmd_results_new(CMD_SUCCESS, NULL, NULL); return cmd_results_new(CMD_SUCCESS, NULL, NULL);
} }
static struct cmd_results *bar_cmd_swaybar_command(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "swaybar_command", EXPECTED_AT_LEAST, 1))) {
return error;
}
if (!config->current_bar) {
return cmd_results_new(CMD_FAILURE, "swaybar_command", "No bar defined.");
}
free(config->current_bar->swaybar_command);
config->current_bar->swaybar_command = join_args(argv, argc);
sway_log(L_DEBUG, "Using custom swaybar command: %s", config->current_bar->swaybar_command);
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}
static struct cmd_results *bar_cmd_tray_output(int argc, char **argv) { static struct cmd_results *bar_cmd_tray_output(int argc, char **argv) {
sway_log(L_ERROR, "warning: tray_output is not supported on wayland"); sway_log(L_ERROR, "warning: tray_output is not supported on wayland");
return cmd_results_new(CMD_SUCCESS, NULL, NULL); return cmd_results_new(CMD_SUCCESS, NULL, NULL);
@ -1986,6 +2004,7 @@ static struct cmd_handler bar_handlers[] = {
{ "separator_symbol", bar_cmd_separator_symbol }, { "separator_symbol", bar_cmd_separator_symbol },
{ "status_command", bar_cmd_status_command }, { "status_command", bar_cmd_status_command },
{ "strip_workspace_numbers", bar_cmd_strip_workspace_numbers }, { "strip_workspace_numbers", bar_cmd_strip_workspace_numbers },
{ "swaybar_command", bar_cmd_swaybar_command },
{ "tray_output", bar_cmd_tray_output }, { "tray_output", bar_cmd_tray_output },
{ "tray_padding", bar_cmd_tray_padding }, { "tray_padding", bar_cmd_tray_padding },
{ "workspace_buttons", bar_cmd_workspace_buttons }, { "workspace_buttons", bar_cmd_workspace_buttons },

View file

@ -673,6 +673,7 @@ struct bar_config *default_bar_config(void) {
bar->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; bar->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM;
bar->bindings = create_list(); bar->bindings = create_list();
bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done"); bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done");
bar->swaybar_command = NULL;
bar->font = strdup("monospace 10"); bar->font = strdup("monospace 10");
bar->height = -1; bar->height = -1;
bar->workspace_buttons = true; bar->workspace_buttons = true;