mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-09-21 14:31:56 +00:00
working prototype
This commit is contained in:
parent
bd86c42cba
commit
75f23cbaa7
7 changed files with 201 additions and 540 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
|||
/bin
|
||||
bin
|
||||
.ccls-cache
|
||||
.DS_Store
|
||||
.ccls
|
||||
|
|
238
src/bar.c
238
src/bar.c
|
@ -175,6 +175,20 @@ out:
|
|||
return desktop_cnt;
|
||||
}
|
||||
|
||||
int bar_get_center_length(struct bar_manager* bar_manager) {
|
||||
int total_length = 0;
|
||||
for (int i = 0; i < bar_manager->bar_item_count; i++) {
|
||||
struct bar_item* bar_item = bar_manager->bar_items[i];
|
||||
if (bar_item->position == 'c') {
|
||||
total_length += bar_item->label_line.bounds.size.width + bar_item->icon_line.bounds.size.width + bar_item->icon_spacing_right + bar_item->label_spacing_left;
|
||||
if (i > 0) {
|
||||
total_length += bar_manager->bar_items[i-1]->label_spacing_right + bar_item->icon_spacing_left;
|
||||
}
|
||||
}
|
||||
}
|
||||
return total_length;
|
||||
}
|
||||
|
||||
void bar_refresh(struct bar *bar)
|
||||
{
|
||||
SLSDisableUpdate(g_connection);
|
||||
|
@ -183,206 +197,50 @@ void bar_refresh(struct bar *bar)
|
|||
CGContextSetRGBFillColor(bar->context, g_bar_manager.background_color.r, g_bar_manager.background_color.g, g_bar_manager.background_color.b, g_bar_manager.background_color.a);
|
||||
CGContextFillRect(bar->context, bar->frame);
|
||||
CGContextStrokePath(bar->context);
|
||||
|
||||
//
|
||||
// BAR LEFT
|
||||
//
|
||||
uint32_t did = display_arrangement(bar->did);
|
||||
uint32_t sid = mission_control_index(display_space_id(bar->did));
|
||||
bar_manager_update_components(&g_bar_manager, did, sid);
|
||||
|
||||
int bar_left_final_item_x = g_bar_manager.padding_left;
|
||||
if (g_bar_manager.spaces) {
|
||||
int space_count;
|
||||
|
||||
if (g_bar_manager.spaces_for_all_displays) {
|
||||
uint32_t display_count = display_manager_active_display_count();
|
||||
for (uint32_t d_index = 1; d_index <= display_count; d_index++)
|
||||
{
|
||||
uint32_t did = display_manager_arrangement_display_id(d_index);
|
||||
uint64_t *space_list = display_space_list(did, &space_count);
|
||||
|
||||
uint64_t sid = display_space_id(did);
|
||||
|
||||
for (int i = 0; i < space_count; ++i) {
|
||||
CGPoint pos = CGContextGetTextPosition(bar->context);
|
||||
|
||||
int index = mission_control_index(space_list[i]) - 1;
|
||||
|
||||
struct bar_line space_line = index >= buf_len(g_bar_manager.space_icon_strip)
|
||||
? g_bar_manager.space_icon
|
||||
: g_bar_manager.space_icon_strip[index];
|
||||
if (i == 0) {
|
||||
pos = bar_align_line(bar, space_line, ALIGN_LEFT, ALIGN_CENTER);
|
||||
pos.x = bar_left_final_item_x;
|
||||
} else {
|
||||
//pos.x += g_bar_manager.spacing_left;
|
||||
}
|
||||
|
||||
bar_left_final_item_x = pos.x; //+ g_bar_manager.spacing_left;
|
||||
|
||||
if (sid == space_list[i]) {
|
||||
if (d_index == 1) {
|
||||
space_line.color = g_bar_manager.space_icon_color;
|
||||
} else if (d_index == 2) {
|
||||
space_line.color = g_bar_manager.space_icon_color_secondary;
|
||||
} else if (d_index == 3) {
|
||||
space_line.color = g_bar_manager.space_icon_color_tertiary;
|
||||
}
|
||||
}
|
||||
|
||||
bar_draw_line(bar, space_line, pos.x, pos.y);
|
||||
}
|
||||
|
||||
if ((d_index < display_count) && g_bar_manager.display_separator) {
|
||||
struct bar_line display_separator_icon = g_bar_manager.display_separator_icon;
|
||||
CGPoint s_pos = bar_align_line(bar, display_separator_icon, 0, ALIGN_CENTER);
|
||||
s_pos.x = bar_left_final_item_x;
|
||||
bar_left_final_item_x = s_pos.x; //+ g_bar_manager.spacing_left;
|
||||
bar_draw_line(bar, display_separator_icon, s_pos.x, s_pos.y);
|
||||
}
|
||||
|
||||
free(space_list);
|
||||
}
|
||||
} else {
|
||||
uint64_t *space_list = display_space_list(bar->did, &space_count);
|
||||
if (space_list) {
|
||||
uint64_t sid = display_space_id(bar->did);
|
||||
|
||||
for (int i = 0; i < space_count; ++i) {
|
||||
CGPoint pos = CGContextGetTextPosition(bar->context);
|
||||
|
||||
int index = mission_control_index(space_list[i]) - 1;
|
||||
|
||||
struct bar_line space_line = index >= buf_len(g_bar_manager.space_icon_strip)
|
||||
? g_bar_manager.space_icon
|
||||
: g_bar_manager.space_icon_strip[index];
|
||||
if (i == 0) {
|
||||
pos = bar_align_line(bar, space_line, ALIGN_LEFT, ALIGN_CENTER);
|
||||
pos.x = bar_left_final_item_x;
|
||||
} else {
|
||||
//pos.x += g_bar_manager.spacing_left;
|
||||
}
|
||||
|
||||
bar_left_final_item_x = pos.x; //+ g_bar_manager.spacing_left;
|
||||
|
||||
if (sid == space_list[i]) {
|
||||
space_line.color = g_bar_manager.space_icon_color;
|
||||
}
|
||||
bar_draw_line(bar, space_line, pos.x, pos.y);
|
||||
|
||||
}
|
||||
free(space_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < g_bar_manager.bar_item_count; i++) {
|
||||
struct bar_item* bar_item = g_bar_manager.bar_items[i];
|
||||
if (bar_item->position != 'l') continue;
|
||||
|
||||
struct bar_line icon = bar_item->icon_line;
|
||||
CGPoint li_pos = bar_align_line(bar, icon, 0, ALIGN_CENTER);
|
||||
li_pos.x = bar_left_final_item_x + 5;
|
||||
bar_draw_line(bar, icon, li_pos.x, li_pos.y);
|
||||
|
||||
struct bar_line label = bar_item->label_line;
|
||||
CGPoint lso_pos = bar_align_line(bar, label, ALIGN_LEFT, ALIGN_CENTER);
|
||||
lso_pos.x = li_pos.x + label.bounds.size.width + 5;
|
||||
|
||||
bar_left_final_item_x = lso_pos.x + label.bounds.size.width + bar_item->label_spacing_right;
|
||||
bar_draw_line(bar, label, lso_pos.x, lso_pos.y);
|
||||
}
|
||||
|
||||
//
|
||||
// BAR RIGHT
|
||||
//
|
||||
|
||||
int bar_right_first_item_x = bar->frame.size.width - g_bar_manager.padding_right;
|
||||
int bar_center_first_item_x = (bar->frame.size.width - bar_get_center_length(&g_bar_manager)) / 2;
|
||||
|
||||
for (int i = 0; i < g_bar_manager.bar_item_count; i++) {
|
||||
struct bar_item* bar_item = g_bar_manager.bar_items[i];
|
||||
if (bar_item->position != 'r') continue;
|
||||
struct bar_line label = bar_item->label_line;
|
||||
CGPoint rso_pos = bar_align_line(bar, label, ALIGN_RIGHT, ALIGN_CENTER);
|
||||
rso_pos.x = bar_right_first_item_x - label.bounds.size.width;
|
||||
bar_draw_line(bar, label, rso_pos.x, rso_pos.y);
|
||||
struct bar_line* label = &bar_item->label_line;
|
||||
struct bar_line* icon = &bar_item->icon_line;
|
||||
CGPoint icon_position = bar_align_line(bar, *icon, ALIGN_CENTER, ALIGN_CENTER);
|
||||
CGPoint label_position = bar_align_line(bar, *label, ALIGN_CENTER, ALIGN_CENTER);
|
||||
|
||||
struct bar_line icon = bar_item->icon_line;
|
||||
CGPoint ri_pos = bar_align_line(bar, icon, 0, ALIGN_CENTER);
|
||||
ri_pos.x = rso_pos.x - icon.bounds.size.width - 5;
|
||||
bar_right_first_item_x = ri_pos.x - bar_item->label_spacing_left;
|
||||
|
||||
bar_draw_line(bar, icon, ri_pos.x, ri_pos.y);
|
||||
if(bar_item->associated_display > 0 && bar_item->associated_display != did) continue;
|
||||
if(bar_item->type != BAR_COMPONENT && bar_item->associated_space > 0 && bar_item->associated_space != did) continue;
|
||||
|
||||
if (bar_item->position == BAR_POSITION_LEFT) {
|
||||
icon_position.x = bar_left_final_item_x + bar_item->icon_spacing_left;
|
||||
label_position.x = icon_position.x + label->bounds.size.width + bar_item->icon_spacing_right + bar_item->label_spacing_left;
|
||||
bar_left_final_item_x = label_position.x + label->bounds.size.width + bar_item->label_spacing_right;
|
||||
}
|
||||
|
||||
if (bar_item->position == BAR_POSITION_RIGHT) {
|
||||
label_position.x = bar_right_first_item_x - label->bounds.size.width - bar_item->label_spacing_right;
|
||||
icon_position.x = label_position.x - icon->bounds.size.width - bar_item->icon_spacing_right - bar_item->label_spacing_left;
|
||||
bar_right_first_item_x = icon_position.x - bar_item->icon_spacing_left;
|
||||
}
|
||||
|
||||
if (bar_item->position == BAR_POSITION_CENTER) {
|
||||
icon_position.x = bar_center_first_item_x + bar_item->icon_spacing_left;
|
||||
label_position.x = icon_position.x + label->bounds.size.width + bar_item->icon_spacing_right + bar_item->label_spacing_left;
|
||||
bar_center_first_item_x = label_position.x + label->bounds.size.width + bar_item->label_spacing_right;
|
||||
}
|
||||
|
||||
bar_draw_line(bar, *icon, icon_position.x, icon_position.y);
|
||||
bar_draw_line(bar, *label, label_position.x, label_position.y);
|
||||
}
|
||||
|
||||
// BAR CENTER
|
||||
if (g_bar_manager.title) {
|
||||
char *title = focused_window_title();
|
||||
if (title) {
|
||||
int overlap_right = 0;
|
||||
|
||||
struct bar_line title_line = bar_prepare_line(g_bar_manager.t_font, title, g_bar_manager.foreground_color);
|
||||
CGPoint pos = bar_align_line(bar, title_line, ALIGN_CENTER, ALIGN_CENTER);
|
||||
|
||||
if (bar_left_final_item_x >= pos.x) {
|
||||
pos.x = bar_left_final_item_x + 100;
|
||||
}
|
||||
|
||||
if (bar_right_first_item_x <= (pos.x + title_line.bounds.size.width)) {
|
||||
overlap_right = (pos.x + title_line.bounds.size.width) - bar_right_first_item_x;
|
||||
}
|
||||
|
||||
if (overlap_right > 0) {
|
||||
int truncated_width = (int)title_line.bounds.size.width - (overlap_right + 100);
|
||||
if (truncated_width > 0) {
|
||||
CTLineRef truncated_line = CTLineCreateTruncatedLine(title_line.line, truncated_width, kCTLineTruncationEnd, NULL);
|
||||
CFRelease(title_line.line);
|
||||
title_line.line = truncated_line;
|
||||
} else {
|
||||
goto free_title;
|
||||
}
|
||||
}
|
||||
|
||||
bar_draw_line(bar, title_line, pos.x, pos.y);
|
||||
free_title:
|
||||
bar_destroy_line(title_line);
|
||||
free(title);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*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);
|
||||
|
||||
if (bar_left_final_item_x >= pos.x) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (overlap_right > 0) {
|
||||
int truncated_width = (int)center_shell_line.bounds.size.width - (overlap_right + 100);
|
||||
if (truncated_width > 0) {
|
||||
CTLineRef truncated_line = CTLineCreateTruncatedLine(center_shell_line.line, truncated_width, kCTLineTruncationEnd, NULL);
|
||||
CFRelease(center_shell_line.line);
|
||||
center_shell_line.line = truncated_line;
|
||||
} else {
|
||||
goto destroy_center;
|
||||
}
|
||||
}
|
||||
|
||||
bar_draw_line(bar, center_shell_line, pos.x, pos.y);
|
||||
destroy_center:
|
||||
bar_destroy_line(center_shell_line);
|
||||
}*/
|
||||
|
||||
|
||||
CGContextFlush(bar->context);
|
||||
SLSOrderWindow(g_connection, bar->id, 1, bar->id);
|
||||
SLSReenableUpdate(g_connection);
|
||||
CGContextFlush(bar->context);
|
||||
SLSOrderWindow(g_connection, bar->id, 1, bar->id);
|
||||
SLSReenableUpdate(g_connection);
|
||||
}
|
||||
|
||||
static CGPoint bar_create_frame(struct bar *bar, CFTypeRef *frame_region)
|
||||
|
|
|
@ -8,16 +8,18 @@ struct bar_item* bar_item_create() {
|
|||
|
||||
void bar_item_init(struct bar_item* bar_item) {
|
||||
bar_item->name = "";
|
||||
bar_item->type = BAR_ITEM;
|
||||
bar_item->update_frequency = 5;
|
||||
bar_item->script = "";
|
||||
bar_item->position = 'r';
|
||||
bar_item->position = BAR_POSITION_RIGHT;
|
||||
bar_item->associated_display = 0;
|
||||
bar_item->associated_space = 0;
|
||||
bar_item->padding_left = 5;
|
||||
bar_item->padding_right = 5;
|
||||
bar_item_set_icon_font(bar_item, string_copy("Hack Nerd Font:Bold:14.0"));
|
||||
bar_item_set_icon(bar_item, string_copy(""));
|
||||
bar_item->switch_icon_side = false;
|
||||
bar_item->icon_spacing_left = 2;
|
||||
bar_item->icon_spacing_right = 2;
|
||||
bar_item->icon_spacing_left = 5;
|
||||
bar_item->icon_spacing_right = 5;
|
||||
bar_item->icon_color = rgba_color_from_hex(0xffffffff);
|
||||
bar_item_set_label_font(bar_item, string_copy("Hack Nerd Font:Bold:14.0"));
|
||||
bar_item_set_label(bar_item, string_copy(""));
|
||||
|
@ -26,6 +28,25 @@ void bar_item_init(struct bar_item* bar_item) {
|
|||
bar_item->label_color = rgba_color_from_hex(0xffffffff);
|
||||
}
|
||||
|
||||
void bar_item_update_component(struct bar_item* bar_item, uint32_t did, uint32_t sid) {
|
||||
if (bar_item->type == BAR_COMPONENT) {
|
||||
if (strcmp(bar_item->identifier, "title") == 0) {
|
||||
bar_item_set_label(bar_item, focused_window_title());
|
||||
}
|
||||
else if (strcmp(bar_item->identifier, "space") == 0) {
|
||||
printf("sid: %i did: %i \n", sid, did);
|
||||
if (sid == bar_item->associated_space && did == bar_item->associated_display) {
|
||||
bar_item->icon_color = g_bar_manager.space_icon_color;
|
||||
bar_item_set_icon(bar_item, bar_item->icon);
|
||||
}
|
||||
else {
|
||||
bar_item->icon_color = g_bar_manager.foreground_color;
|
||||
bar_item_set_icon(bar_item, bar_item->icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bar_item_set_name(struct bar_item* bar_item, char* name) {
|
||||
if (name != bar_item->name && !bar_item->name) {
|
||||
free(bar_item->name);
|
||||
|
|
|
@ -1,7 +1,20 @@
|
|||
#ifndef BAR_ITEM_H
|
||||
#define BAR_ITEM_H
|
||||
|
||||
#define BAR_ITEM 'i'
|
||||
#define BAR_COMPONENT 'c'
|
||||
#define BAR_PLUGIN 'p'
|
||||
|
||||
#define BAR_POSITION_LEFT 'l'
|
||||
#define BAR_POSITION_RIGHT 'r'
|
||||
#define BAR_POSITION_CENTER 'c'
|
||||
|
||||
struct bar_item {
|
||||
char type;
|
||||
char* identifier;
|
||||
|
||||
uint32_t associated_display;
|
||||
uint32_t associated_space;
|
||||
uint32_t update_frequency;
|
||||
// Execute with exec_fork, callback from command via messages
|
||||
char* script;
|
||||
|
@ -20,7 +33,6 @@ struct bar_item {
|
|||
struct bar_line icon_line;
|
||||
char* icon;
|
||||
CTFontRef icon_font;
|
||||
bool switch_icon_side; // true: left, false: right
|
||||
uint32_t icon_spacing_left;
|
||||
uint32_t icon_spacing_right;
|
||||
struct rgba_color icon_color;
|
||||
|
@ -42,6 +54,7 @@ struct bar_item {
|
|||
};
|
||||
|
||||
struct bar_item* bar_item_create();
|
||||
void bar_item_update_component(struct bar_item* bar_item, uint32_t did, uint32_t sid);
|
||||
void bar_item_init(struct bar_item* bar_item);
|
||||
void bar_item_set_name(struct bar_item* bar_item, char* name);
|
||||
void bar_item_set_script(struct bar_item* bar_item, char* script);
|
||||
|
@ -56,6 +69,4 @@ void bar_item_set_separator_right(struct bar_item* bar_item, char* sep);
|
|||
void bar_item_set_label_font(struct bar_item* bar_item, char *font_string);
|
||||
void bar_item_set_icon_font(struct bar_item* bar_item, char *font_string);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,17 +12,14 @@ int bar_manager_get_item_index_for_name(struct bar_manager* bar_manager, char* n
|
|||
|
||||
void bar_manager_set_foreground_color(struct bar_manager *bar_manager, uint32_t color)
|
||||
{
|
||||
bar_manager->foreground_color = rgba_color_from_hex(color);
|
||||
if (bar_manager->_space_icon_strip) bar_manager_set_space_strip(bar_manager, bar_manager->_space_icon_strip);
|
||||
if (bar_manager->_space_icon) bar_manager_set_space_icon(bar_manager, bar_manager->_space_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);
|
||||
bar_manager->foreground_color = rgba_color_from_hex(color);
|
||||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_background_color(struct bar_manager *bar_manager, uint32_t color)
|
||||
{
|
||||
bar_manager->background_color = rgba_color_from_hex(color);
|
||||
bar_manager_refresh(bar_manager);
|
||||
bar_manager->background_color = rgba_color_from_hex(color);
|
||||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_space_icon_color(struct bar_manager *bar_manager, uint32_t color)
|
||||
|
@ -31,128 +28,6 @@ void bar_manager_set_space_icon_color(struct bar_manager *bar_manager, uint32_t
|
|||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_space_icon_color_secondary(struct bar_manager *bar_manager, uint32_t color)
|
||||
{
|
||||
bar_manager->space_icon_color_secondary = rgba_color_from_hex(color);
|
||||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_space_icon_color_tertiary(struct bar_manager *bar_manager, uint32_t color)
|
||||
{
|
||||
bar_manager->space_icon_color_tertiary = 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);
|
||||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_text_font(struct bar_manager *bar_manager, char *font_string)
|
||||
{
|
||||
if (bar_manager->t_font) {
|
||||
CFRelease(bar_manager->t_font);
|
||||
}
|
||||
|
||||
if (font_string != bar_manager->t_font_prop) {
|
||||
if (bar_manager->t_font_prop) {
|
||||
free(bar_manager->t_font_prop);
|
||||
}
|
||||
|
||||
bar_manager->t_font_prop = font_string;
|
||||
}
|
||||
|
||||
bar_manager->t_font = bar_create_font(bar_manager->t_font_prop);
|
||||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_icon_font(struct bar_manager *bar_manager, char *font_string)
|
||||
{
|
||||
if (bar_manager->i_font) {
|
||||
CFRelease(bar_manager->i_font);
|
||||
}
|
||||
|
||||
if (font_string != bar_manager->i_font_prop) {
|
||||
if (bar_manager->i_font_prop) {
|
||||
free(bar_manager->i_font_prop);
|
||||
}
|
||||
|
||||
bar_manager->i_font_prop = font_string;
|
||||
}
|
||||
|
||||
bar_manager->i_font = bar_create_font(bar_manager->i_font_prop);
|
||||
if (bar_manager->_space_icon_strip) bar_manager_set_space_strip(bar_manager, bar_manager->_space_icon_strip);
|
||||
if (bar_manager->_space_icon) bar_manager_set_space_icon(bar_manager, bar_manager->_space_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);
|
||||
}
|
||||
|
||||
void bar_manager_set_space_strip(struct bar_manager *bar_manager, char **icon_strip)
|
||||
{
|
||||
for (int i = 0; i < buf_len(bar_manager->space_icon_strip); ++i) {
|
||||
bar_destroy_line(bar_manager->space_icon_strip[i]);
|
||||
}
|
||||
|
||||
buf_free(bar_manager->space_icon_strip);
|
||||
bar_manager->space_icon_strip = NULL;
|
||||
|
||||
if (icon_strip != bar_manager->_space_icon_strip) {
|
||||
for (int i = 0; i < buf_len(bar_manager->_space_icon_strip); ++i) {
|
||||
free(bar_manager->_space_icon_strip[i]);
|
||||
}
|
||||
|
||||
buf_free(bar_manager->_space_icon_strip);
|
||||
bar_manager->_space_icon_strip = icon_strip;
|
||||
}
|
||||
|
||||
for (int i = 0; i < buf_len(bar_manager->_space_icon_strip); ++i) {
|
||||
struct bar_line space_line = bar_prepare_line(bar_manager->i_font, bar_manager->_space_icon_strip[i], bar_manager->foreground_color);
|
||||
buf_push(bar_manager->space_icon_strip, space_line);
|
||||
}
|
||||
|
||||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_space_icon(struct bar_manager *bar_manager, char *icon)
|
||||
{
|
||||
if (bar_manager->space_icon.line) {
|
||||
bar_destroy_line(bar_manager->space_icon);
|
||||
}
|
||||
|
||||
if (icon != bar_manager->_space_icon) {
|
||||
if (bar_manager->_space_icon) {
|
||||
free(bar_manager->_space_icon);
|
||||
}
|
||||
|
||||
bar_manager->_space_icon = icon;
|
||||
}
|
||||
|
||||
bar_manager->space_icon = bar_prepare_line(bar_manager->i_font, bar_manager->_space_icon, bar_manager->foreground_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) {
|
||||
bar_destroy_line(bar_manager->display_separator_icon);
|
||||
}
|
||||
|
||||
if (icon != bar_manager->_display_separator_icon) {
|
||||
if (bar_manager->_display_separator_icon) {
|
||||
free(bar_manager->_display_separator_icon);
|
||||
}
|
||||
|
||||
bar_manager->_display_separator_icon = icon;
|
||||
}
|
||||
|
||||
bar_manager->display_separator_icon = bar_prepare_line(bar_manager->i_font, bar_manager->_display_separator_icon, bar_manager->display_separator_icon_color);
|
||||
|
||||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_position(struct bar_manager *bar_manager, char *pos)
|
||||
{
|
||||
bar_manager->position = pos;
|
||||
|
@ -165,24 +40,6 @@ void bar_manager_set_title(struct bar_manager *bar_manager, bool value)
|
|||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_spaces(struct bar_manager *bar_manager, bool value)
|
||||
{
|
||||
bar_manager->spaces = value;
|
||||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_spaces_for_all_displays(struct bar_manager *bar_manager, bool value)
|
||||
{
|
||||
bar_manager->spaces_for_all_displays = value;
|
||||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_display_separator(struct bar_manager *bar_manager, bool value)
|
||||
{
|
||||
bar_manager->display_separator = value;
|
||||
bar_manager_refresh(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_height(struct bar_manager *bar_manager, uint32_t height)
|
||||
{
|
||||
bar_manager->height = height;
|
||||
|
@ -203,10 +60,10 @@ void bar_manager_set_padding_right(struct bar_manager *bar_manager, uint32_t pad
|
|||
|
||||
void bar_manager_display_changed(struct bar_manager *bar_manager)
|
||||
{
|
||||
for (int i = 0; i < bar_manager->bar_count; ++i)
|
||||
bar_destroy(bar_manager->bars[i]);
|
||||
for (int i = 0; i < bar_manager->bar_count; ++i)
|
||||
bar_destroy(bar_manager->bars[i]);
|
||||
|
||||
bar_manager_begin(bar_manager);
|
||||
bar_manager_begin(bar_manager);
|
||||
}
|
||||
|
||||
void bar_manager_set_display(struct bar_manager *bar_manager, char *display)
|
||||
|
@ -221,38 +78,47 @@ void bar_manager_set_display(struct bar_manager *bar_manager, char *display)
|
|||
|
||||
void bar_manager_refresh(struct bar_manager *bar_manager)
|
||||
{
|
||||
for (int i = 0; i < bar_manager->bar_count; ++i)
|
||||
bar_refresh(bar_manager->bars[i]);
|
||||
for (int i = 0; i < bar_manager->bar_count; ++i)
|
||||
bar_refresh(bar_manager->bars[i]);
|
||||
}
|
||||
|
||||
void bar_manager_resize(struct bar_manager *bar_manager)
|
||||
{
|
||||
for (int i = 0; i < bar_manager->bar_count; ++i)
|
||||
bar_resize(bar_manager->bars[i]);
|
||||
for (int i = 0; i < bar_manager->bar_count; ++i)
|
||||
bar_resize(bar_manager->bars[i]);
|
||||
}
|
||||
|
||||
struct bar_item* bar_manager_create_item(struct bar_manager* bar_manager) {
|
||||
bar_manager->bar_items = (struct bar_item**) realloc(bar_manager->bar_items, sizeof(struct bar_item*) * (bar_manager->bar_item_count + 1));
|
||||
bar_manager->bar_item_count += 1;
|
||||
struct bar_item* bar_item = bar_item_create();
|
||||
bar_item_init(bar_item);
|
||||
bar_manager->bar_items[bar_manager->bar_item_count - 1] = bar_item;
|
||||
return bar_item;
|
||||
}
|
||||
|
||||
void bar_manager_init(struct bar_manager *bar_manager)
|
||||
{
|
||||
bar_manager->bars = NULL;
|
||||
bar_manager->bar_count = 0;
|
||||
bar_manager->bar_item_count = 0;
|
||||
bar_manager->display = "all";
|
||||
bar_manager->position = "top";
|
||||
bar_manager->height = 26;
|
||||
bar_manager->title = true;
|
||||
bar_manager->spaces = true;
|
||||
bar_manager->padding_left = 20;
|
||||
bar_manager->padding_right = 20;
|
||||
bar_manager_set_text_font(bar_manager, string_copy("Helvetica Neue:Regular:12.0"));
|
||||
bar_manager_set_icon_font(bar_manager, string_copy("Font Awesome 5 Free:Solid:12.0"));
|
||||
bar_manager->background_color = rgba_color_from_hex(0xff202020);
|
||||
bar_manager->foreground_color = rgba_color_from_hex(0xffa8a8a8);
|
||||
bar_manager->space_icon_color = rgba_color_from_hex(0xffd75f5f);
|
||||
bar_manager->space_icon_color_secondary = rgba_color_from_hex(0xffd75f5f);
|
||||
bar_manager->space_icon_color_tertiary = rgba_color_from_hex(0xffd75f5f);
|
||||
bar_manager_set_space_icon(bar_manager, string_copy("•"));
|
||||
bar_manager_set_display_separator_icon(bar_manager, string_copy("|"));
|
||||
bar_manager->display_separator_icon_color = rgba_color_from_hex(0xffa8a8a8);
|
||||
bar_manager->bars = NULL;
|
||||
bar_manager->bar_count = 0;
|
||||
bar_manager->bar_item_count = 0;
|
||||
bar_manager->display = "all";
|
||||
bar_manager->position = "top";
|
||||
bar_manager->height = 26;
|
||||
bar_manager->title = true;
|
||||
bar_manager->spaces = true;
|
||||
bar_manager->padding_left = 20;
|
||||
bar_manager->padding_right = 20;
|
||||
bar_manager->background_color = rgba_color_from_hex(0xff202020);
|
||||
bar_manager->foreground_color = rgba_color_from_hex(0xffa8a8a8);
|
||||
bar_manager->space_icon_color = rgba_color_from_hex(0xffd75f5f);
|
||||
}
|
||||
|
||||
void bar_manager_update_components(struct bar_manager* bar_manager, uint32_t did, uint32_t sid) {
|
||||
for (int i = 0; i < bar_manager->bar_item_count; i++) {
|
||||
struct bar_item* bar_item = bar_manager->bar_items[i];
|
||||
bar_item_update_component(bar_item, did, sid);
|
||||
}
|
||||
}
|
||||
|
||||
void bar_manager_begin(struct bar_manager *bar_manager)
|
||||
|
|
|
@ -7,37 +7,23 @@ struct bar_manager
|
|||
int bar_count;
|
||||
struct bar_item **bar_items;
|
||||
int bar_item_count;
|
||||
char *t_font_prop;
|
||||
char *i_font_prop;
|
||||
CTFontRef t_font;
|
||||
CTFontRef i_font;
|
||||
char **_space_icon_strip;
|
||||
char **_power_icon_strip;
|
||||
char *_space_icon;
|
||||
char *position;
|
||||
char *display;
|
||||
char *_display_separator_icon;
|
||||
uint32_t height;
|
||||
uint32_t padding_left;
|
||||
uint32_t padding_right;
|
||||
bool title;
|
||||
bool spaces;
|
||||
bool spaces_for_all_displays;
|
||||
bool display_separator;
|
||||
struct rgba_color foreground_color;
|
||||
struct rgba_color background_color;
|
||||
struct rgba_color space_icon_color;
|
||||
struct rgba_color space_icon_color_secondary;
|
||||
struct rgba_color space_icon_color_tertiary;
|
||||
struct rgba_color display_separator_icon_color;
|
||||
struct rgba_color background_color_dim;
|
||||
struct bar_line *space_icon_strip;
|
||||
struct bar_line space_icon;
|
||||
struct bar_line display_separator_icon;
|
||||
};
|
||||
|
||||
int bar_manager_get_item_index_for_name(struct bar_manager* bar_manager, char* name);
|
||||
struct bar_item* bar_manager_create_item(struct bar_manager* bar_manager);
|
||||
|
||||
void bar_manager_update_components(struct bar_manager* bar_manager, uint32_t did, uint32_t sid);
|
||||
void bar_manager_set_foreground_color(struct bar_manager *bar_manager, uint32_t color);
|
||||
void bar_manager_set_background_color(struct bar_manager *bar_manager, uint32_t color);
|
||||
void bar_manager_set_space_icon_color(struct bar_manager *bar_manager, uint32_t color);
|
||||
|
@ -47,7 +33,6 @@ void bar_manager_set_display_separator_icon_color(struct bar_manager *bar_manage
|
|||
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);
|
||||
void bar_manager_set_power_strip(struct bar_manager *bar_manager, char **icon_strip);
|
||||
void bar_manager_set_space_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);
|
||||
|
|
222
src/message.c
222
src/message.c
|
@ -15,9 +15,9 @@ extern bool g_verbose;
|
|||
#define DOMAIN_ADD "add"
|
||||
// Syntax: spacebar -m add item <name> <position>
|
||||
#define COMMAND_ADD_ITEM "item"
|
||||
// Syntax: spacebar -m add component <name> <position>
|
||||
// Syntax: spacebar -m add component <identifier> <name> <position>
|
||||
#define COMMAND_ADD_COMPONENT "component"
|
||||
// Syntax: spacebar -m add plugin <name> <position>
|
||||
// Syntax: spacebar -m add plugin <identifier> <name> <position>
|
||||
#define COMMAND_ADD_PLUGIN "plugin"
|
||||
|
||||
#define DOMAIN_SET "set"
|
||||
|
@ -25,10 +25,15 @@ extern bool g_verbose;
|
|||
/* --------------------------------DOMAIN SET-------------------------------- */
|
||||
|
||||
// Syntax: spacebar -m set <name> <property> <value>
|
||||
#define COMMAND_SET_POSITION "position"
|
||||
#define COMMAND_SET_ASSOCIATED_DISPLAY "associated_display"
|
||||
#define COMMAND_SET_ASSOCIATED_SPACE "associated_space"
|
||||
#define COMMAND_SET_UPDATE_FREQ "update_freq"
|
||||
#define COMMAND_SET_SCRIPT "script"
|
||||
#define COMMAND_SET_PADDING_LEFT "padding_left"
|
||||
#define COMMAND_SET_PADDING_RIGHT "padding_right"
|
||||
#define COMMAND_SET_ICON_PADDING_LEFT "icon_padding_left"
|
||||
#define COMMAND_SET_ICON_PADDING_RIGHT "icon_padding_right"
|
||||
#define COMMAND_SET_LABEL_PADDING_LEFT "label_padding_left"
|
||||
#define COMMAND_SET_LABEL_PADDING_RIGHT "label_padding_right"
|
||||
#define COMMAND_SET_ICON "icon"
|
||||
#define COMMAND_SET_ICON_FONT "icon_font"
|
||||
#define COMMAND_SET_ICON_COLOR "icon_color"
|
||||
|
@ -41,25 +46,14 @@ extern bool g_verbose;
|
|||
|
||||
/* --------------------------------DOMAIN CONFIG-------------------------------- */
|
||||
#define COMMAND_CONFIG_DEBUG_OUTPUT "debug_output"
|
||||
#define COMMAND_CONFIG_BAR_TEXT_FONT "text_font"
|
||||
#define COMMAND_CONFIG_BAR_ICON_FONT "icon_font"
|
||||
#define COMMAND_CONFIG_BAR_SPACE_ICON_COLOR "space_icon_color"
|
||||
#define COMMAND_CONFIG_BAR_SPACE_ICON_COLOR_SECONDARY "space_icon_color_secondary"
|
||||
#define COMMAND_CONFIG_BAR_SPACE_ICON_COLOR_TERTIARY "space_icon_color_tertiary"
|
||||
#define COMMAND_CONFIG_BAR_BACKGROUND "background_color"
|
||||
#define COMMAND_CONFIG_BAR_FOREGROUND "foreground_color"
|
||||
#define COMMAND_CONFIG_BAR_SPACE_STRIP "space_icon_strip"
|
||||
#define COMMAND_CONFIG_BAR_SPACE_ICON "space_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_TITLE "title"
|
||||
#define COMMAND_CONFIG_BAR_SPACES "spaces"
|
||||
#define COMMAND_CONFIG_BAR_SPACES_FOR_ALL_DISPLAYS "spaces_for_all_displays"
|
||||
#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----------------------------- */
|
||||
|
@ -142,23 +136,41 @@ static void daemon_fail(FILE *rsp, char *fmt, ...)
|
|||
view_flush(view); \
|
||||
}
|
||||
|
||||
// Syntax: spacebar -m add <item> <name>
|
||||
// Syntax: spacebar -m add <item|component|plugin> (<identifier>) <name> <position>
|
||||
static void handle_domain_add(FILE* rsp, struct token domain, char* message) {
|
||||
printf("Handling add domain \n");
|
||||
struct token command = get_token(&message);
|
||||
struct token name;
|
||||
struct token position;
|
||||
struct bar_item* bar_item = bar_manager_create_item(&g_bar_manager);
|
||||
|
||||
if (token_equals(command, COMMAND_ADD_ITEM)) {
|
||||
struct token name = get_token(&message);
|
||||
struct token position = get_token(&message);
|
||||
printf("Reallocing \n");
|
||||
g_bar_manager.bar_items = (struct bar_item**) realloc(g_bar_manager.bar_items, sizeof(struct bar_item*) * (g_bar_manager.bar_item_count + 1));
|
||||
g_bar_manager.bar_item_count += 1;
|
||||
g_bar_manager.bar_items[g_bar_manager.bar_item_count - 1] = bar_item_create();
|
||||
printf("Realloced, now we init \n");
|
||||
bar_item_init(g_bar_manager.bar_items[g_bar_manager.bar_item_count - 1]);
|
||||
g_bar_manager.bar_items[g_bar_manager.bar_item_count - 1]->position = token_to_string(position)[0];
|
||||
bar_item_set_name(g_bar_manager.bar_items[g_bar_manager.bar_item_count - 1], string_copy(token_to_string(name)));
|
||||
printf("Init done, now we roll \n");
|
||||
name = get_token(&message);
|
||||
position = get_token(&message);
|
||||
bar_item->type = BAR_ITEM;
|
||||
bar_item->identifier = token_to_string(name);
|
||||
} else if (token_equals(command, COMMAND_ADD_COMPONENT)) {
|
||||
struct token identifier = get_token(&message);
|
||||
name = get_token(&message);
|
||||
position = get_token(&message);
|
||||
|
||||
bar_item->type = BAR_COMPONENT;
|
||||
bar_item->identifier = token_to_string(identifier);
|
||||
} else if (token_equals(command, COMMAND_ADD_PLUGIN)) {
|
||||
struct token identifier = get_token(&message);
|
||||
name = get_token(&message);
|
||||
position = get_token(&message);
|
||||
|
||||
bar_item->type = BAR_PLUGIN;
|
||||
bar_item->identifier = token_to_string(identifier);
|
||||
}
|
||||
else {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
bar_item->position = token_to_string(position)[0];
|
||||
bar_item_set_name(bar_item, string_copy(token_to_string(name)));
|
||||
|
||||
bar_manager_refresh(&g_bar_manager);
|
||||
}
|
||||
|
||||
// Syntax: spacebar -m set <name> <property> <value>
|
||||
|
@ -171,27 +183,49 @@ static void handle_domain_set(FILE* rsp, struct token domain, char* message) {
|
|||
printf("Name not found in bar items");
|
||||
return;
|
||||
}
|
||||
struct bar_item* bar_item = g_bar_manager.bar_items[item_index_for_name];
|
||||
|
||||
if (token_equals(property, COMMAND_SET_ICON)) {
|
||||
bar_item_set_icon(g_bar_manager.bar_items[item_index_for_name], string_copy(message));
|
||||
bar_item_set_icon(bar_item, string_copy(message));
|
||||
} else if (token_equals(property, COMMAND_SET_ICON_FONT)) {
|
||||
bar_item_set_icon_font(g_bar_manager.bar_items[item_index_for_name], string_copy(message));
|
||||
bar_item_set_icon_font(bar_item, string_copy(message));
|
||||
} else if (token_equals(property, COMMAND_SET_LABEL)) {
|
||||
bar_item_set_label(g_bar_manager.bar_items[item_index_for_name], string_copy(message));
|
||||
bar_item_set_label(bar_item, string_copy(message));
|
||||
} else if (token_equals(property, COMMAND_SET_LABEL_FONT)) {
|
||||
bar_item_set_label_font(g_bar_manager.bar_items[item_index_for_name], string_copy(message));
|
||||
bar_item_set_label_font(bar_item, string_copy(message));
|
||||
} else if (token_equals(property, COMMAND_SET_SCRIPT)) {
|
||||
bar_item_set_script(g_bar_manager.bar_items[item_index_for_name], string_copy(message));
|
||||
bar_item_set_script(bar_item, string_copy(message));
|
||||
} else if (token_equals(property, COMMAND_SET_UPDATE_FREQ)) {
|
||||
struct token value = get_token(&message);
|
||||
g_bar_manager.bar_items[item_index_for_name]->update_frequency = token_to_uint32t(value);
|
||||
bar_item->update_frequency = token_to_uint32t(value);
|
||||
} else if (token_equals(property, COMMAND_SET_LABEL_COLOR)) {
|
||||
struct token value = get_token(&message);
|
||||
bar_item_set_label_color(g_bar_manager.bar_items[item_index_for_name], token_to_uint32t(value));
|
||||
bar_item_set_label_color(bar_item, token_to_uint32t(value));
|
||||
} else if (token_equals(property, COMMAND_SET_ICON_COLOR)) {
|
||||
struct token value = get_token(&message);
|
||||
bar_item_set_icon_color(g_bar_manager.bar_items[item_index_for_name], token_to_uint32t(value));
|
||||
}
|
||||
bar_item_set_icon_color(bar_item, token_to_uint32t(value));
|
||||
} else if (token_equals(property, COMMAND_SET_POSITION)) {
|
||||
struct token value = get_token(&message);
|
||||
bar_item->position = token_to_string(value)[0];
|
||||
} else if (token_equals(property, COMMAND_SET_ASSOCIATED_SPACE)) {
|
||||
struct token value = get_token(&message);
|
||||
bar_item->associated_space = token_to_uint32t(value);
|
||||
} else if (token_equals(property, COMMAND_SET_ASSOCIATED_DISPLAY)) {
|
||||
struct token value = get_token(&message);
|
||||
bar_item->associated_display = token_to_uint32t(value);
|
||||
} else if (token_equals(property, COMMAND_SET_ICON_PADDING_LEFT)) {
|
||||
struct token value = get_token(&message);
|
||||
bar_item->icon_spacing_left = token_to_uint32t(value);
|
||||
} else if (token_equals(property, COMMAND_SET_ICON_PADDING_RIGHT)) {
|
||||
struct token value = get_token(&message);
|
||||
bar_item->icon_spacing_right = token_to_uint32t(value);
|
||||
} else if (token_equals(property, COMMAND_SET_LABEL_PADDING_LEFT)) {
|
||||
struct token value = get_token(&message);
|
||||
bar_item->label_spacing_left = token_to_uint32t(value);
|
||||
} else if (token_equals(property, COMMAND_SET_LABEL_PADDING_RIGHT)) {
|
||||
struct token value = get_token(&message);
|
||||
bar_item->label_spacing_left = token_to_uint32t(value);
|
||||
}
|
||||
|
||||
bar_manager_refresh(&g_bar_manager);
|
||||
}
|
||||
|
@ -211,20 +245,6 @@ static void handle_domain_config(FILE *rsp, struct token domain, char *message)
|
|||
} else {
|
||||
daemon_fail(rsp, "unknown value '%.*s' given to command '%.*s' for domain '%.*s'\n", value.length, value.text, command.length, command.text, domain.length, domain.text);
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_TEXT_FONT)) {
|
||||
int length = strlen(message);
|
||||
if (length <= 0) {
|
||||
fprintf(rsp, "%s\n", g_bar_manager.t_font_prop);
|
||||
} else {
|
||||
bar_manager_set_text_font(&g_bar_manager, string_copy(message));
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_ICON_FONT)) {
|
||||
int length = strlen(message);
|
||||
if (length <= 0) {
|
||||
fprintf(rsp, "%s\n", g_bar_manager.i_font_prop);
|
||||
} else {
|
||||
bar_manager_set_icon_font(&g_bar_manager, string_copy(message));
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_BACKGROUND)) {
|
||||
struct token value = get_token(&message);
|
||||
if (!token_is_valid(value)) {
|
||||
|
@ -249,30 +269,6 @@ static void handle_domain_config(FILE *rsp, struct token domain, char *message)
|
|||
daemon_fail(rsp, "unknown value '%.*s' given to command '%.*s' for domain '%.*s'\n", value.length, value.text, command.length, command.text, domain.length, domain.text);
|
||||
}
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_SPACE_STRIP)) {
|
||||
char **icon_strip = NULL;
|
||||
struct token token = get_token(&message);
|
||||
|
||||
if(token.length==0){ // If no value given, print current value
|
||||
fprintf(rsp, "\"%s\"", *g_bar_manager._space_icon_strip);
|
||||
char **p = g_bar_manager._space_icon_strip;
|
||||
for(int i = 1; i<buf_len(g_bar_manager.space_icon_strip);i++) {
|
||||
fprintf(rsp, " \"%s\"", *++p);
|
||||
}
|
||||
} else { // Else, set value
|
||||
while (token.text && token.length > 0) {
|
||||
buf_push(icon_strip, token_to_string(token));
|
||||
token = get_token(&message);
|
||||
}
|
||||
bar_manager_set_space_strip(&g_bar_manager, icon_strip);
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_SPACE_ICON)) {
|
||||
struct token token = get_token(&message);
|
||||
if (!token_is_valid(token)) {
|
||||
fprintf(rsp, "%s\n", g_bar_manager._space_icon ? g_bar_manager._space_icon : "");
|
||||
} else {
|
||||
bar_manager_set_space_icon(&g_bar_manager, token_to_string(token));
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_SPACE_ICON_COLOR)) {
|
||||
struct token value = get_token(&message);
|
||||
if (!token_is_valid(value)) {
|
||||
|
@ -285,30 +281,6 @@ static void handle_domain_config(FILE *rsp, struct token domain, char *message)
|
|||
daemon_fail(rsp, "unknown value '%.*s' given to command '%.*s' for domain '%.*s'\n", value.length, value.text, command.length, command.text, domain.length, domain.text);
|
||||
}
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_SPACE_ICON_COLOR_SECONDARY)) {
|
||||
struct token value = get_token(&message);
|
||||
if (!token_is_valid(value)) {
|
||||
fprintf(rsp, "0x%x\n", g_bar_manager.space_icon_color_secondary.p);
|
||||
} else {
|
||||
uint32_t color = token_to_uint32t(value);
|
||||
if (color) {
|
||||
bar_manager_set_space_icon_color_secondary(&g_bar_manager, color);
|
||||
} else {
|
||||
daemon_fail(rsp, "unknown value '%.*s' given to command '%.*s' for domain '%.*s'\n", value.length, value.text, command.length, command.text, domain.length, domain.text);
|
||||
}
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_SPACE_ICON_COLOR_TERTIARY)) {
|
||||
struct token value = get_token(&message);
|
||||
if (!token_is_valid(value)) {
|
||||
fprintf(rsp, "0x%x\n", g_bar_manager.space_icon_color_tertiary.p);
|
||||
} else {
|
||||
uint32_t color = token_to_uint32t(value);
|
||||
if (color) {
|
||||
bar_manager_set_space_icon_color_tertiary(&g_bar_manager, color);
|
||||
} else {
|
||||
daemon_fail(rsp, "unknown value '%.*s' given to command '%.*s' for domain '%.*s'\n", value.length, value.text, command.length, command.text, domain.length, domain.text);
|
||||
}
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_HEIGHT)) {
|
||||
struct token token = get_token(&message);
|
||||
if (!token_is_valid(token)) {
|
||||
|
@ -343,58 +315,6 @@ static void handle_domain_config(FILE *rsp, struct token domain, char *message)
|
|||
} else {
|
||||
daemon_fail(rsp, "unknown value '%.*s' given to command '%.*s' for domain '%.*s'\n", value.length, value.text, command.length, command.text, domain.length, domain.text);
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_SPACES)) {
|
||||
struct token value = get_token(&message);
|
||||
if (!token_is_valid(value)) {
|
||||
fprintf(rsp, "%s\n", bool_str[g_bar_manager.spaces]);
|
||||
} else if (token_equals(value, ARGUMENT_COMMON_VAL_OFF)) {
|
||||
bar_manager_set_spaces(&g_bar_manager, false);
|
||||
} else if (token_equals(value, ARGUMENT_COMMON_VAL_ON)) {
|
||||
bar_manager_set_spaces(&g_bar_manager, true);
|
||||
} else {
|
||||
daemon_fail(rsp, "unknown value '%.*s' given to command '%.*s' for domain '%.*s'\n", value.length, value.text, command.length, command.text, domain.length, domain.text);
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_SPACES_FOR_ALL_DISPLAYS)) {
|
||||
struct token value = get_token(&message);
|
||||
if (!token_is_valid(value)) {
|
||||
fprintf(rsp, "%s\n", bool_str[g_bar_manager.spaces_for_all_displays]);
|
||||
} else if (token_equals(value, ARGUMENT_COMMON_VAL_OFF)) {
|
||||
bar_manager_set_spaces_for_all_displays(&g_bar_manager, false);
|
||||
} else if (token_equals(value, ARGUMENT_COMMON_VAL_ON)) {
|
||||
bar_manager_set_spaces_for_all_displays(&g_bar_manager, true);
|
||||
} else {
|
||||
daemon_fail(rsp, "unknown value '%.*s' given to command '%.*s' for domain '%.*s'\n", value.length, value.text, command.length, command.text, domain.length, domain.text);
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_DISPLAY_SEPARATOR)) {
|
||||
struct token value = get_token(&message);
|
||||
if (!token_is_valid(value)) {
|
||||
fprintf(rsp, "%s\n", bool_str[g_bar_manager.display_separator]);
|
||||
} else if (token_equals(value, ARGUMENT_COMMON_VAL_OFF)) {
|
||||
bar_manager_set_display_separator(&g_bar_manager, false);
|
||||
} else if (token_equals(value, ARGUMENT_COMMON_VAL_ON)) {
|
||||
bar_manager_set_display_separator(&g_bar_manager, true);
|
||||
} else {
|
||||
daemon_fail(rsp, "unknown value '%.*s' given to command '%.*s' for domain '%.*s'\n", value.length, value.text, command.length, command.text, domain.length, domain.text);
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_DISPLAY_SEPARATOR_ICON_COLOR)) {
|
||||
struct token value = get_token(&message);
|
||||
if (!token_is_valid(value)) {
|
||||
fprintf(rsp, "0x%x\n", g_bar_manager.display_separator_icon_color.p);
|
||||
} else {
|
||||
uint32_t color = token_to_uint32t(value);
|
||||
if (color) {
|
||||
bar_manager_set_display_separator_icon_color(&g_bar_manager, color);
|
||||
} else {
|
||||
daemon_fail(rsp, "unknown value '%.*s' given to command '%.*s' for domain '%.*s'\n", value.length, value.text, command.length, command.text, domain.length, domain.text);
|
||||
}
|
||||
}
|
||||
} else if (token_equals(command, COMMAND_CONFIG_BAR_DISPLAY_SEPARATOR_ICON)) {
|
||||
struct token token = get_token(&message);
|
||||
if (!token_is_valid(token)) {
|
||||
fprintf(rsp, "%s\n", g_bar_manager._display_separator_icon ? g_bar_manager._display_separator_icon : "");
|
||||
} 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";
|
||||
|
|
Loading…
Reference in a new issue