mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-10 22:04:28 +00:00
feature: Option to draw single bar or multiple bars, per display
Closes #47
This commit is contained in:
parent
1b0d1d644f
commit
9feb85f469
6 changed files with 49 additions and 2 deletions
|
@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
- Option to set the padding between the first/last item and the left/right edge of the display
|
||||
- Default to "Solid" style of Font Awesome 5 Free icon font
|
||||
- Option to display spaces for all displays, including: optional separator, secondary & tertiary space indicator colours in relation to display
|
||||
- Option to specify only drawing one bar on the main display or multiple bars, one for each display (this aligns with yabai's `external_bar` option)
|
||||
|
||||
## [1.2.1](https://github.com/cmacrae/spacebar/releases/tag/v1.2.1) - 2020-11-18
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
.\" Title: spacebar
|
||||
.\" Author: [see the "AUTHOR(S)" section]
|
||||
.\" Generator: Asciidoctor 2.0.10
|
||||
.\" Date: 2021-04-07
|
||||
.\" Date: 2021-04-08
|
||||
.\" Manual: spacebar manual
|
||||
.\" Source: spacebar
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "SPACEBAR" "1" "2021-04-07" "spacebar" "spacebar manual"
|
||||
.TH "SPACEBAR" "1" "2021-04-08" "spacebar" "spacebar manual"
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.ss \n[.ss] 0
|
||||
|
@ -70,6 +70,13 @@ Get or set the value of <setting>.
|
|||
Enable output of debug information to stdout.
|
||||
.RE
|
||||
.sp
|
||||
\fBdisplay\fP [\fI<display>\fP]
|
||||
.RS 4
|
||||
Display to draw the bar on.
|
||||
.br
|
||||
Must be one of \fImain\fP or \fIall\fP.
|
||||
.RE
|
||||
.sp
|
||||
\fBposition\fP [\fI<position>\fP]
|
||||
.RS 4
|
||||
Position on the screen to draw the bar.
|
||||
|
|
|
@ -60,6 +60,10 @@ Settings
|
|||
*debug_output* ['<BOOL_SEL>']::
|
||||
Enable output of debug information to stdout.
|
||||
|
||||
*display* ['<display>']::
|
||||
Display to draw the bar on. +
|
||||
Must be one of 'main' or 'all'.
|
||||
|
||||
*position* ['<position>']::
|
||||
Position on the screen to draw the bar. +
|
||||
Must be one of 'top' or 'bottom'.
|
||||
|
|
|
@ -432,6 +432,16 @@ void bar_manager_display_changed(struct bar_manager *bar_manager)
|
|||
bar_manager_begin(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_display(struct bar_manager *bar_manager, char *display)
|
||||
{
|
||||
bar_manager->display = display;
|
||||
|
||||
for (int i = 0; i < bar_manager->bar_count; ++i)
|
||||
bar_destroy(bar_manager->bars[i]);
|
||||
|
||||
bar_manager_begin(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_refresh(struct bar_manager *bar_manager)
|
||||
{
|
||||
for (int i = 0; i < bar_manager->bar_count; ++i)
|
||||
|
@ -448,6 +458,7 @@ void bar_manager_init(struct bar_manager *bar_manager)
|
|||
{
|
||||
bar_manager->bars = NULL;
|
||||
bar_manager->bar_count = 0;
|
||||
bar_manager->display = "all";
|
||||
bar_manager_set_position(bar_manager, string_copy("top"));
|
||||
bar_manager_set_height(bar_manager, 26);
|
||||
bar_manager_set_title(bar_manager, true);
|
||||
|
@ -493,6 +504,15 @@ void bar_manager_init(struct bar_manager *bar_manager)
|
|||
|
||||
void bar_manager_begin(struct bar_manager *bar_manager)
|
||||
{
|
||||
char * main = "main";
|
||||
char * all = "all";
|
||||
|
||||
if (strcmp(bar_manager->display,main) == 0) {
|
||||
uint32_t did = display_manager_main_display_id();
|
||||
bar_manager->bars = (struct bar **) realloc(bar_manager->bars, sizeof(struct bar *) * 1);
|
||||
bar_manager->bar_count = 1;
|
||||
bar_manager->bars[0] = bar_create(did);
|
||||
} else if (strcmp(bar_manager->display,all) == 0) {
|
||||
bar_manager->bar_count = display_manager_active_display_count();
|
||||
bar_manager->bars = (struct bar **) realloc(bar_manager->bars, sizeof(struct bar *) * bar_manager->bar_count);
|
||||
|
||||
|
@ -501,4 +521,5 @@ void bar_manager_begin(struct bar_manager *bar_manager)
|
|||
uint32_t did = display_manager_arrangement_display_id(index);
|
||||
bar_manager->bars[index - 1] = bar_create(did);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ struct bar_manager
|
|||
char *_left_shell_icon;
|
||||
char *_right_shell_icon;
|
||||
char *position;
|
||||
char *display;
|
||||
char *_display_separator_icon;
|
||||
uint32_t height;
|
||||
uint32_t padding_left;
|
||||
|
@ -110,6 +111,7 @@ void bar_manager_set_center_shell_output(struct bar_manager *bar_manager, char *
|
|||
void bar_manager_set_left_shell_command(struct bar_manager *bar_manager, char *command);
|
||||
void bar_manager_set_right_shell_command(struct bar_manager *bar_manager, char *command);
|
||||
void bar_manager_set_center_shell_command(struct bar_manager *bar_manager, char *command);
|
||||
void bar_manager_set_display(struct bar_manager *bar_manager, char *display);
|
||||
|
||||
void bar_manager_display_changed(struct bar_manager *bar_manager);
|
||||
void bar_manager_refresh(struct bar_manager *bar_manager);
|
||||
|
|
|
@ -53,6 +53,7 @@ extern bool g_verbose;
|
|||
#define COMMAND_CONFIG_BAR_DISPLAY_SEPARATOR "display_separator"
|
||||
#define COMMAND_CONFIG_BAR_DISPLAY_SEPARATOR_ICON "display_separator_icon"
|
||||
#define COMMAND_CONFIG_BAR_DISPLAY_SEPARATOR_ICON_COLOR "display_separator_icon_color"
|
||||
#define COMMAND_CONFIG_BAR_DISPLAY "display"
|
||||
|
||||
/* --------------------------------COMMON ARGUMENTS----------------------------- */
|
||||
#define ARGUMENT_COMMON_VAL_ON "on"
|
||||
|
@ -554,6 +555,17 @@ static void handle_domain_config(FILE *rsp, struct token domain, char *message)
|
|||
} else {
|
||||
bar_manager_set_display_separator_icon(&g_bar_manager, token_to_string(token));
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_DISPLAY)) {
|
||||
int length = strlen(message);
|
||||
char * main = "main";
|
||||
char * all = "all";
|
||||
if (length <= 0) {
|
||||
fprintf(rsp, "%s\n", g_bar_manager.display);
|
||||
} else if ((strcmp(message,main) == 0) || (strcmp(message,all) == 0)) {
|
||||
bar_manager_set_display(&g_bar_manager, string_copy(message));
|
||||
} else {
|
||||
daemon_fail(rsp, "value for '%.*s' must be either 'main' or 'all'.\n", command.length, command.text);
|
||||
}
|
||||
}
|
||||
else {
|
||||
daemon_fail(rsp, "unknown command '%.*s' for domain '%.*s'\n", command.length, command.text, domain.length, domain.text);
|
||||
|
|
Loading…
Reference in a new issue