Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion doc/spacebar.1
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,16 @@ Command pipeline to retrieve the output for displaying in the right shell sectio
There is NO timeout protection for the command pipeline, so be sure to set it to something that returns output quickly.
.RE
.sp
\fBcenter_shell_icon\fP [\fI<sym>\fP]
.RS 4
Specify a symbol to prefix the center shell output.
.RE
.sp
\fBcenter_shell_icon_color\fP [\fI<COLOR>\fP]
.RS 4
Color to use for drawing the center shell icon.
.RE
.sp
\fBcenter_shell_command\fP [\fI<shell command>\fP]
.RS 4
Command pipeline to retrieve the output for displaying in the center shell section.
Expand All @@ -310,4 +320,4 @@ There is NO timeout protection for the command pipeline, so be sure to set it to
If \fBspacebar\fP can\(cqt handle a message, it will return a non\-zero exit code.
.SH "AUTHOR"
.sp
Calum MacRae <hi at cmacr.ae>
Calum MacRae <hi at cmacr.ae>
6 changes: 6 additions & 0 deletions doc/spacebar.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ Settings
Command pipeline to retrieve the output for displaying in the right shell section. +
There is NO timeout protection for the command pipeline, so be sure to set it to something that returns output quickly.

*center_shell_icon* ['<sym>']::
Specify a symbol to prefix the center shell output.

*center_shell_icon_color* ['<COLOR>']::
Color to use for drawing the center shell icon.

*center_shell_command* ['<shell command>']::
Command pipeline to retrieve the output for displaying in the center shell section. +
There is NO timeout protection for the command pipeline, so be sure to set it to something that returns output quickly. +
Expand Down
23 changes: 16 additions & 7 deletions src/bar.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,16 +453,25 @@ void bar_refresh(struct bar *bar)
if (g_bar_manager.center_shell_on) {
int overlap_right = 0;

struct bar_line center_shell_line = bar_prepare_line(g_bar_manager.t_font, g_bar_manager.center_shell_output, g_bar_manager.foreground_color);
CGPoint pos = bar_align_line(bar, center_shell_line, ALIGN_CENTER, ALIGN_CENTER);
struct bar_line center_shell_line = bar_prepare_line(g_bar_manager.t_font, g_bar_manager.center_shell_output, g_bar_manager.foreground_color);
CGPoint pos = bar_align_line(bar, center_shell_line, ALIGN_CENTER, ALIGN_CENTER);

if (bar_left_final_item_x >= pos.x) {
pos.x = bar_left_final_item_x + 100;
}
struct bar_line cso_icon = g_bar_manager.center_shell_icon;
cso_icon.color = g_bar_manager.center_shell_icon_color;
CGPoint ci_pos = bar_align_line(bar, cso_icon, 0, ALIGN_CENTER);
ci_pos.x = pos.x - cso_icon.bounds.size.width - 5;
bar_center_first_item_x = ci_pos.x - g_bar_manager.spacing_right;

bar_draw_line(bar, cso_icon, ci_pos.x, ci_pos.y);

if (bar_left_final_item_x >= ci_pos.x) {
ci_pos.x = bar_left_final_item_x + 100;
pos.x = bar_left_final_item_x + 100;
}

if (bar_right_first_item_x <= (pos.x + center_shell_line.bounds.size.width)) {
overlap_right = (pos.x + center_shell_line.bounds.size.width) - bar_right_first_item_x;
}
overlap_right = (pos.x + center_shell_line.bounds.size.width) - bar_right_first_item_x;
}

if (overlap_right > 0) {
int truncated_width = (int)center_shell_line.bounds.size.width - (overlap_right + 100);
Expand Down
29 changes: 29 additions & 0 deletions src/bar_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ void bar_manager_set_foreground_color(struct bar_manager *bar_manager, uint32_t
if (bar_manager->_space_icon) bar_manager_set_space_icon(bar_manager, bar_manager->_space_icon);
if (bar_manager->_left_shell_icon) bar_manager_set_left_shell_icon(bar_manager, bar_manager->_left_shell_icon);
if (bar_manager->_right_shell_icon) bar_manager_set_right_shell_icon(bar_manager, bar_manager->_right_shell_icon);
if (bar_manager->_center_shell_icon) bar_manager_set_center_shell_icon(bar_manager, bar_manager->_center_shell_icon);
if (bar_manager->_display_separator_icon) bar_manager_set_display_separator_icon(bar_manager, bar_manager->_display_separator_icon);
bar_manager_refresh(bar_manager);
}
Expand Down Expand Up @@ -74,6 +75,12 @@ void bar_manager_set_right_shell_icon_color(struct bar_manager *bar_manager, uin
bar_manager_refresh(bar_manager);
}

void bar_manager_set_center_shell_icon_color(struct bar_manager *bar_manager, uint32_t color)
{
bar_manager->center_shell_icon_color = rgba_color_from_hex(color);
bar_manager_refresh(bar_manager);
}

void bar_manager_set_display_separator_icon_color(struct bar_manager *bar_manager, uint32_t color)
{
bar_manager->display_separator_icon_color = rgba_color_from_hex(color);
Expand Down Expand Up @@ -120,6 +127,7 @@ void bar_manager_set_icon_font(struct bar_manager *bar_manager, char *font_strin
if (bar_manager->_dnd_icon) bar_manager_set_dnd_icon(bar_manager, bar_manager->_dnd_icon);
if (bar_manager->_left_shell_icon) bar_manager_set_left_shell_icon(bar_manager, bar_manager->_left_shell_icon);
if (bar_manager->_right_shell_icon) bar_manager_set_right_shell_icon(bar_manager, bar_manager->_right_shell_icon);
if (bar_manager->_center_shell_icon) bar_manager_set_center_shell_icon(bar_manager, bar_manager->_center_shell_icon);
if (bar_manager->_display_separator_icon) bar_manager_set_display_separator_icon(bar_manager, bar_manager->_display_separator_icon);
bar_manager_refresh(bar_manager);
}
Expand Down Expand Up @@ -282,6 +290,25 @@ void bar_manager_set_right_shell_icon(struct bar_manager *bar_manager, char *ico
bar_manager_refresh(bar_manager);
}

void bar_manager_set_center_shell_icon(struct bar_manager *bar_manager, char *icon)
{
if (bar_manager->center_shell_icon.line) {
bar_destroy_line(bar_manager->center_shell_icon);
}

if (icon != bar_manager->_center_shell_icon) {
if (bar_manager->_center_shell_icon) {
free(bar_manager->_center_shell_icon);
}

bar_manager->_center_shell_icon = icon;
}

bar_manager->center_shell_icon = bar_prepare_line(bar_manager->i_font, bar_manager->_center_shell_icon, bar_manager->center_shell_icon_color);

bar_manager_refresh(bar_manager);
}

void bar_manager_set_display_separator_icon(struct bar_manager *bar_manager, char *icon)
{
if (bar_manager->display_separator_icon.line) {
Expand Down Expand Up @@ -567,6 +594,8 @@ void bar_manager_init(struct bar_manager *bar_manager)
bar_manager->left_shell_icon_color = rgba_color_from_hex(0xffa8a8a8);
bar_manager_set_right_shell_icon(bar_manager, string_copy(""));
bar_manager->right_shell_icon_color = rgba_color_from_hex(0xffa8a8a8);
bar_manager_set_center_shell_icon(bar_manager, string_copy(""));
bar_manager->center_shell_icon_color = rgba_color_from_hex(0xffa8a8a8);
bar_manager->left_shell_output = "";
bar_manager->right_shell_output = "";
bar_manager->center_shell_output = "";
Expand Down
5 changes: 5 additions & 0 deletions src/bar_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct bar_manager
char *_dnd_icon;
char *_left_shell_icon;
char *_right_shell_icon;
char *_center_shell_icon;
char *position;
char *display;
char *_display_separator_icon;
Expand Down Expand Up @@ -52,6 +53,7 @@ struct bar_manager
struct rgba_color dnd_icon_color;
struct rgba_color left_shell_icon_color;
struct rgba_color right_shell_icon_color;
struct rgba_color center_shell_icon_color;
struct rgba_color display_separator_icon_color;
struct rgba_color background_color_dim;
struct bar_line *space_icon_strip;
Expand All @@ -64,6 +66,7 @@ struct bar_manager
struct bar_line left_shell_icon;
struct bar_line right_shell;
struct bar_line right_shell_icon;
struct bar_line center_shell_icon;
struct bar_line center_shell;
struct bar_line display_separator_icon;
};
Expand All @@ -80,6 +83,7 @@ void bar_manager_set_dnd_icon_color(struct bar_manager *bar_manager, uint32_t co
void bar_manager_set_display_separator_icon_color(struct bar_manager *bar_manager, uint32_t color);
void bar_manager_set_left_shell_icon_color(struct bar_manager *bar_manager, uint32_t color);
void bar_manager_set_right_shell_icon_color(struct bar_manager *bar_manager, uint32_t color);
void bar_manager_set_center_shell_icon_color(struct bar_manager *bar_manager, uint32_t color);
void bar_manager_set_text_font(struct bar_manager *bar_manager, char *font_string);
void bar_manager_set_icon_font(struct bar_manager *bar_manager, char *font_string);
void bar_manager_set_space_strip(struct bar_manager *bar_manager, char **icon_strip);
Expand All @@ -93,6 +97,7 @@ void bar_manager_set_left_shell_icon(struct bar_manager *bar_manager, char *icon
void bar_manager_set_display_separator(struct bar_manager *bar_manager, bool value);
void bar_manager_set_display_separator_icon(struct bar_manager *bar_manager, char *icon);
void bar_manager_set_right_shell_icon(struct bar_manager *bar_manager, char *icon);
void bar_manager_set_center_shell_icon(struct bar_manager *bar_manager, char *icon);
void bar_manager_set_position(struct bar_manager *bar_manager, char *pos);
void bar_manager_set_title(struct bar_manager *bar_manager, bool value);
void bar_manager_set_spaces(struct bar_manager *bar_manager, bool value);
Expand Down
Loading