mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-22 19:33:03 +00:00
feature: Add padding options
This commit is contained in:
parent
e4d5e6fa57
commit
c9305ddf33
9 changed files with 60 additions and 3 deletions
|
@ -11,11 +11,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
- Fixed a bug introduced in Big Sur where buffer reads were incorrect
|
||||
|
||||
**Added**
|
||||
- New `left|center|right` shell sections: display custom text based on shell pipelines
|
||||
- Option to turn focused window title display on or off (thanks [@Norviah](https://github.com/Norviah)!)
|
||||
- Option to turn the spaces indicator on or off
|
||||
- Option to turn the clock on or off
|
||||
- Option to turn the power indicator on or off
|
||||
- New `left|center|right` shell sections: display custom text based on shell pipelines
|
||||
- Option to set the padding between the first/last item and the left/right edge of the display
|
||||
|
||||
## [1.2.1](https://github.com/cmacrae/spacebar/releases/tag/v1.2.1) - 2020-11-18
|
||||
|
||||
|
|
|
@ -76,6 +76,8 @@ spacebar -m config title on
|
|||
spacebar -m config spaces on
|
||||
spacebar -m config clock on
|
||||
spacebar -m config power on
|
||||
spacebar -m config padding_left 20
|
||||
spacebar -m config padding_right 20
|
||||
spacebar -m config spacing_left 25
|
||||
spacebar -m config spacing_right 15
|
||||
spacebar -m config text_font "Helvetica Neue:Bold:12.0"
|
||||
|
@ -115,6 +117,8 @@ If you're using the `services.spacebar` module from [nix-darwin](https://github.
|
|||
spaces = "on";
|
||||
clock = "on";
|
||||
power = "on";
|
||||
padding_left = 20;
|
||||
padding_right = 20;
|
||||
spacing_left = 25;
|
||||
spacing_right = 15;
|
||||
text_font = ''"Helvetica Neue:Bold:12.0"'';
|
||||
|
|
|
@ -104,6 +104,16 @@ Enable clock on the right of the bar.
|
|||
Enable power indicator on the right of the bar.
|
||||
.RE
|
||||
.sp
|
||||
\fBpadding_left\fP [\fI<NUM>\fP]
|
||||
.RS 4
|
||||
Padding in pixels between the left edge of the display and the first item.
|
||||
.RE
|
||||
.sp
|
||||
\fBpadding_right\fP [\fI<NUM>\fP]
|
||||
.RS 4
|
||||
Padding in pixels between the right edge of the display and the last item.
|
||||
.RE
|
||||
.sp
|
||||
\fBspacing_left\fP [\fI<NUM>\fP]
|
||||
.RS 4
|
||||
Spacing in pixels between the left space indicators.
|
||||
|
|
|
@ -80,6 +80,12 @@ Settings
|
|||
*power* ['<BOOL_SEL>']::
|
||||
Enable power indicator on the right of the bar.
|
||||
|
||||
*padding_left* ['<NUM>']::
|
||||
Padding in pixels between the left edge of the display and the first item.
|
||||
|
||||
*padding_right* ['<NUM>']::
|
||||
Padding in pixels between the right edge of the display and the last item.
|
||||
|
||||
*spacing_left* ['<NUM>']::
|
||||
Spacing in pixels between the left space indicators.
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ spacebar -m config title on
|
|||
spacebar -m config spaces on
|
||||
spacebar -m config clock on
|
||||
spacebar -m config power on
|
||||
spacebar -m config padding_left 20
|
||||
spacebar -m config padding_right 20
|
||||
spacebar -m config spacing_left 25
|
||||
spacebar -m config spacing_right 15
|
||||
spacebar -m config text_font "Helvetica Neue:Bold:12.0"
|
||||
|
|
|
@ -267,7 +267,7 @@ void bar_refresh(struct bar *bar)
|
|||
// BAR LEFT
|
||||
//
|
||||
|
||||
int bar_left_final_item_x = 20;
|
||||
int bar_left_final_item_x = g_bar_manager.padding_left;
|
||||
if (g_bar_manager.spaces) {
|
||||
int space_count;
|
||||
uint64_t *space_list = display_space_list(bar->did, &space_count);
|
||||
|
@ -323,7 +323,7 @@ void bar_refresh(struct bar *bar)
|
|||
|
||||
// This is used to calculate overlap for the cetner bar.
|
||||
// It is updated to represent the X position of the first item, depending on what's displayed.
|
||||
int bar_right_first_item_x = bar->frame.size.width - 20;
|
||||
int bar_right_first_item_x = bar->frame.size.width - g_bar_manager.padding_right;
|
||||
if (g_bar_manager.clock) {
|
||||
time_t rawtime;
|
||||
time(&rawtime);
|
||||
|
|
|
@ -294,6 +294,18 @@ void bar_manager_set_height(struct bar_manager *bar_manager, uint32_t height)
|
|||
bar_manager_resize(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_padding_left(struct bar_manager *bar_manager, uint32_t padding)
|
||||
{
|
||||
bar_manager->padding_left = padding;
|
||||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_padding_right(struct bar_manager *bar_manager, uint32_t padding)
|
||||
{
|
||||
bar_manager->padding_right = padding;
|
||||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_spacing_left(struct bar_manager *bar_manager, uint32_t spacing)
|
||||
{
|
||||
bar_manager->spacing_left = spacing;
|
||||
|
@ -381,6 +393,8 @@ void bar_manager_init(struct bar_manager *bar_manager)
|
|||
bar_manager_set_spaces(bar_manager, true);
|
||||
bar_manager_set_clock(bar_manager, true);
|
||||
bar_manager_set_power(bar_manager, true);
|
||||
bar_manager_set_padding_left(bar_manager, 20);
|
||||
bar_manager_set_padding_right(bar_manager, 20);
|
||||
bar_manager_set_spacing_left(bar_manager, 25);
|
||||
bar_manager_set_spacing_right(bar_manager, 15);
|
||||
bar_manager_set_text_font(bar_manager, string_copy("Helvetica Neue:Regular:10.0"));
|
||||
|
|
|
@ -19,6 +19,8 @@ struct bar_manager
|
|||
char *_right_shell_icon;
|
||||
char *position;
|
||||
uint32_t height;
|
||||
uint32_t padding_left;
|
||||
uint32_t padding_right;
|
||||
uint32_t spacing_left;
|
||||
uint32_t spacing_right;
|
||||
bool title;
|
||||
|
@ -82,6 +84,8 @@ void bar_manager_set_spaces(struct bar_manager *bar_manager, bool value);
|
|||
void bar_manager_set_clock(struct bar_manager *bar_manager, bool value);
|
||||
void bar_manager_set_power(struct bar_manager *bar_manager, bool value);
|
||||
void bar_manager_set_height(struct bar_manager *bar_manager, uint32_t height);
|
||||
void bar_manager_set_padding_left(struct bar_manager *bar_manager, uint32_t padding);
|
||||
void bar_manager_set_padding_right(struct bar_manager *bar_manager, uint32_t padding);
|
||||
void bar_manager_set_spacing_left(struct bar_manager *bar_manager, uint32_t spacing);
|
||||
void bar_manager_set_spacing_right(struct bar_manager *bar_manager, uint32_t spacing);
|
||||
void bar_manager_set_left_shell(struct bar_manager *bar_manager, bool value);
|
||||
|
|
|
@ -29,6 +29,8 @@ extern bool g_verbose;
|
|||
#define COMMAND_CONFIG_BAR_DND_ICON "dnd_icon"
|
||||
#define COMMAND_CONFIG_BAR_POSITION "position"
|
||||
#define COMMAND_CONFIG_BAR_HEIGHT "height"
|
||||
#define COMMAND_CONFIG_BAR_PADDING_LEFT "padding_left"
|
||||
#define COMMAND_CONFIG_BAR_PADDING_RIGHT "padding_right"
|
||||
#define COMMAND_CONFIG_BAR_SPACING_LEFT "spacing_left"
|
||||
#define COMMAND_CONFIG_BAR_SPACING_RIGHT "spacing_right"
|
||||
#define COMMAND_CONFIG_BAR_TITLE "title"
|
||||
|
@ -313,6 +315,20 @@ static void handle_domain_config(FILE *rsp, struct token domain, char *message)
|
|||
} else {
|
||||
bar_manager_set_height(&g_bar_manager, atoi(token_to_string(token)));
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_PADDING_LEFT)) {
|
||||
struct token token = get_token(&message);
|
||||
if (!token_is_valid(token)) {
|
||||
fprintf(rsp, "%"PRIu32"\n", g_bar_manager.padding_left ? g_bar_manager.padding_left : 0);
|
||||
} else {
|
||||
bar_manager_set_padding_left(&g_bar_manager, atoi(token_to_string(token)));
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_PADDING_RIGHT)) {
|
||||
struct token token = get_token(&message);
|
||||
if (!token_is_valid(token)) {
|
||||
fprintf(rsp, "%"PRIu32"\n", g_bar_manager.padding_right ? g_bar_manager.padding_right : 0);
|
||||
} else {
|
||||
bar_manager_set_padding_right(&g_bar_manager, atoi(token_to_string(token)));
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_SPACING_LEFT)) {
|
||||
struct token token = get_token(&message);
|
||||
if (!token_is_valid(token)) {
|
||||
|
|
Loading…
Reference in a new issue