Merge branch 'feature/spaces_for_all_displays'

This commit is contained in:
Calum MacRae 2021-04-07 15:54:31 +01:00
commit 1b0d1d644f
No known key found for this signature in database
GPG key ID: 53922D7E54A14F5D
7 changed files with 435 additions and 172 deletions

View file

@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Option to turn the power indicator on or off
- 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
## [1.2.1](https://github.com/cmacrae/spacebar/releases/tag/v1.2.1) - 2020-11-18

View file

@ -2,12 +2,12 @@
.\" Title: spacebar
.\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 2.0.10
.\" Date: 2021-03-30
.\" Date: 2021-04-07
.\" Manual: spacebar manual
.\" Source: spacebar
.\" Language: English
.\"
.TH "SPACEBAR" "1" "2021-03-30" "spacebar" "spacebar manual"
.TH "SPACEBAR" "1" "2021-04-07" "spacebar" "spacebar manual"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.ss \n[.ss] 0
@ -94,6 +94,51 @@ This cannot be enabled when \fIcenter_shell\(cqis set to \(aqon\fP.
Enable space indicator on the left of the bar.
.RE
.sp
\fBspace_icon_strip\fP [\fI<sym_1> <sym_2> <sym_n>\fP]
.RS 4
Specify symbols separated by whitespace to be used for visualizing spaces.
.RE
.sp
\fBspaces_for_all_displays\fP [\fI<BOOL_SEL>\fP]
.RS 4
Enable space indicators for spaces on each display.
.RE
.sp
\fBspace_icon\fP [\fI<sym>\fP]
.RS 4
Specify a general symbol to use for any given space that does not have a match in \fIspace_icon_strip\fP.
.RE
.sp
\fBspace_icon_color\fP [\fI<COLOR>\fP]
.RS 4
Color to use for drawing the current space icon.
.RE
.sp
\fBspace_icon_color_secondary\fP [\fI<COLOR>\fP]
.RS 4
Color to use for drawing the current space icon of the second display.
.RE
.sp
\fBspace_icon_color_tertiary\fP [\fI<COLOR>\fP]
.RS 4
Color to use for drawing the current space icon of the third display.
.RE
.sp
\fBdisplay_separator\fP [\fI<BOOL_SEL>\fP]
.RS 4
Enable separator between the spaces for each display.
.RE
.sp
\fBdisplay_separator_icon\fP [\fI<sym>\fP]
.RS 4
Specify a symbol to use for the display separator.
.RE
.sp
\fBdisplay_separator_icon_color\fP [\fI<COLOR>\fP]
.RS 4
Color to use for drawing the display separator icon.
.RE
.sp
\fBclock\fP [\fI<BOOL_SEL>\fP]
.RS 4
Enable clock on the right of the bar.
@ -148,11 +193,6 @@ Color to use for drawing status bar background.
Color to use for drawing status bar elements.
.RE
.sp
\fBspace_icon_strip\fP [\fI<sym_1> <sym_2> <sym_n>\fP]
.RS 4
Specify symbols separated by whitespace to be used for visualizing spaces.
.RE
.sp
\fBpower_icon_strip\fP [\fI<sym_battery> <sym_ac>\fP]
.RS 4
Specify two symbols separated by whitespace.
@ -170,16 +210,6 @@ Color to use for drawing the power (charging) icon.
Color to use for drawing the battery icon.
.RE
.sp
\fBspace_icon\fP [\fI<sym>\fP]
.RS 4
Specify a general symbol to use for any given space that does not have a match in \fIspace_icon_strip\fP.
.RE
.sp
\fBspace_icon_color\fP [\fI<COLOR>\fP]
.RS 4
Color to use for drawing the current space icon.
.RE
.sp
\fBclock_icon\fP [\fI<sym>\fP]
.RS 4
Specify a symbol to represent the current time.

View file

@ -74,6 +74,33 @@ Settings
*spaces* ['<BOOL_SEL>']::
Enable space indicator on the left of the bar.
*space_icon_strip* ['<sym_1> <sym_2> <sym_n>']::
Specify symbols separated by whitespace to be used for visualizing spaces.
*spaces_for_all_displays* ['<BOOL_SEL>']::
Enable space indicators for spaces on each display.
*space_icon* ['<sym>']::
Specify a general symbol to use for any given space that does not have a match in 'space_icon_strip'.
*space_icon_color* ['<COLOR>']::
Color to use for drawing the current space icon.
*space_icon_color_secondary* ['<COLOR>']::
Color to use for drawing the current space icon of the second display.
*space_icon_color_tertiary* ['<COLOR>']::
Color to use for drawing the current space icon of the third display.
*display_separator* ['<BOOL_SEL>']::
Enable separator between the spaces for each display.
*display_separator_icon* ['<sym>']::
Specify a symbol to use for the display separator.
*display_separator_icon_color* ['<COLOR>']::
Color to use for drawing the display separator icon.
*clock* ['<BOOL_SEL>']::
Enable clock on the right of the bar.
@ -106,9 +133,6 @@ Settings
*foreground_color* ['<COLOR>']::
Color to use for drawing status bar elements.
*space_icon_strip* ['<sym_1> <sym_2> <sym_n>']::
Specify symbols separated by whitespace to be used for visualizing spaces.
*power_icon_strip* ['<sym_battery> <sym_ac>']::
Specify two symbols separated by whitespace. +
The first symbol represents battery power and the second symbol indicates AC.
@ -119,12 +143,6 @@ Settings
*battery_icon_color* ['<COLOR>']::
Color to use for drawing the battery icon.
*space_icon* ['<sym>']::
Specify a general symbol to use for any given space that does not have a match in 'space_icon_strip'.
*space_icon_color* ['<COLOR>']::
Color to use for drawing the current space icon.
*clock_icon* ['<sym>']::
Specify a symbol to represent the current time.

View file

@ -61,20 +61,19 @@ static char* run_shell(char *command)
{
FILE *fp;
char path[2048];
char* string;
char* out;
fp = popen(command, "r");
if (fp == NULL) {
printf("error running command\n" );
exit(1);
return string_copy("error running command");
}
while (fgets(path, sizeof(path), fp) != NULL) {
string = string_copy(path);
out = string_copy(path);
}
pclose(fp);
return string;
return out;
}
static void set_shell_outputs(struct bar_manager *bar_manager)
@ -82,18 +81,24 @@ static void set_shell_outputs(struct bar_manager *bar_manager)
char* left_shell_output;
char* right_shell_output;
char* center_shell_output;
if (strlen(bar_manager->left_shell_command) >= 0) {
if ((strlen(bar_manager->left_shell_command) > 0) && bar_manager->left_shell_on) {
left_shell_output = run_shell(string_copy(bar_manager->left_shell_command));
if (strlen(left_shell_output) > 0) {
bar_manager_set_left_shell_output(bar_manager, left_shell_output);
}
if (strlen(bar_manager->right_shell_command) >= 0) {
}
if ((strlen(bar_manager->right_shell_command) > 0) && bar_manager->right_shell_on) {
right_shell_output = run_shell(string_copy(bar_manager->right_shell_command));
if (strlen(right_shell_output) > 0) {
bar_manager_set_right_shell_output(bar_manager, right_shell_output);
}
if (strlen(bar_manager->center_shell_command) >= 0) {
}
if ((strlen(bar_manager->center_shell_command) > 0) && bar_manager->center_shell_on) {
center_shell_output = run_shell(string_copy(bar_manager->center_shell_command));
if (strlen(center_shell_output) > 0) {
bar_manager_set_center_shell_output(bar_manager, center_shell_output);
}
}
}
static CTFontRef bar_create_font(char *cstring)
@ -270,6 +275,57 @@ void bar_refresh(struct bar *bar)
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);
@ -302,6 +358,8 @@ void bar_refresh(struct bar *bar)
}
}
}
if(g_bar_manager.left_shell_on) {
struct bar_line lso_icon = g_bar_manager.left_shell_icon;
lso_icon.color = g_bar_manager.left_shell_icon_color;

View file

@ -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->_display_separator_icon) bar_manager_set_display_separator_icon(bar_manager, bar_manager->_display_separator_icon);
bar_manager_refresh(bar_manager);
}
@ -25,6 +26,18 @@ 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_battery_icon_color(struct bar_manager *bar_manager, uint32_t color)
{
bar_manager->battery_icon_color = rgba_color_from_hex(color);
@ -61,6 +74,12 @@ void bar_manager_set_right_shell_icon_color(struct bar_manager *bar_manager, uin
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) {
@ -101,6 +120,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->_display_separator_icon) bar_manager_set_display_separator_icon(bar_manager, bar_manager->_display_separator_icon);
bar_manager_refresh(bar_manager);
}
@ -262,6 +282,25 @@ void bar_manager_set_right_shell_icon(struct bar_manager *bar_manager, char *ico
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;
@ -271,21 +310,37 @@ void bar_manager_set_position(struct bar_manager *bar_manager, char *pos)
void bar_manager_set_title(struct bar_manager *bar_manager, bool value)
{
bar_manager->title = value;
bar_manager_resize(bar_manager);
}
void bar_manager_set_spaces(struct bar_manager *bar_manager, bool value)
{
bar_manager->spaces = value;
bar_manager_resize(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_resize(bar_manager);
}
void bar_manager_set_display_separator(struct bar_manager *bar_manager, bool value)
{
bar_manager->display_separator = value;
bar_manager_resize(bar_manager);
}
void bar_manager_set_clock(struct bar_manager *bar_manager, bool value)
{
bar_manager->clock = value;
bar_manager_resize(bar_manager);
}
void bar_manager_set_power(struct bar_manager *bar_manager, bool value)
{
bar_manager->power = value;
bar_manager_resize(bar_manager);
}
void bar_manager_set_height(struct bar_manager *bar_manager, uint32_t height)
@ -321,16 +376,19 @@ void bar_manager_set_spacing_right(struct bar_manager *bar_manager, uint32_t spa
void bar_manager_set_left_shell(struct bar_manager *bar_manager, bool value)
{
bar_manager->left_shell_on = value;
bar_manager_refresh(bar_manager);
}
void bar_manager_set_right_shell(struct bar_manager *bar_manager, bool value)
{
bar_manager->right_shell_on = value;
bar_manager_refresh(bar_manager);
}
void bar_manager_set_center_shell(struct bar_manager *bar_manager, bool value)
{
bar_manager->center_shell_on = value;
bar_manager_refresh(bar_manager);
}
void bar_manager_set_left_shell_output(struct bar_manager *bar_manager, char *output)
@ -351,16 +409,19 @@ 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)
{
bar_manager->left_shell_command = command;
bar_manager_refresh(bar_manager);
}
void bar_manager_set_right_shell_command(struct bar_manager *bar_manager, char *command)
{
bar_manager->right_shell_command = command;
bar_manager_refresh(bar_manager);
}
void bar_manager_set_center_shell_command(struct bar_manager *bar_manager, char *command)
{
bar_manager->center_shell_command = command;
bar_manager_refresh(bar_manager);
}
void bar_manager_display_changed(struct bar_manager *bar_manager)
@ -402,6 +463,8 @@ void bar_manager_init(struct bar_manager *bar_manager)
bar_manager_set_background_color(bar_manager, 0xff202020);
bar_manager_set_foreground_color(bar_manager, 0xffa8a8a8);
bar_manager_set_space_icon_color(bar_manager, 0xffd75f5f);
bar_manager_set_space_icon_color_secondary(bar_manager, 0xffd75f5f);
bar_manager_set_space_icon_color_tertiary(bar_manager, 0xffd75f5f);
bar_manager_set_battery_icon_color(bar_manager, 0xffd75f5f);
bar_manager_set_power_icon_color(bar_manager, 0xffcd950c);
bar_manager_set_clock_icon_color(bar_manager, 0xffa8a8a8);
@ -421,9 +484,11 @@ void bar_manager_init(struct bar_manager *bar_manager)
bar_manager_set_left_shell_output(bar_manager, string_copy(""));
bar_manager_set_right_shell_output(bar_manager, string_copy(""));
bar_manager_set_center_shell_output(bar_manager, string_copy(""));
bar_manager_set_left_shell_command(bar_manager, string_copy("true"));
bar_manager_set_right_shell_command(bar_manager, string_copy("true"));
bar_manager_set_center_shell_command(bar_manager, string_copy("true"));
bar_manager_set_left_shell_command(bar_manager, string_copy("echo 'left shell'"));
bar_manager_set_right_shell_command(bar_manager, string_copy("echo 'right shell'"));
bar_manager_set_center_shell_command(bar_manager, string_copy("echo 'center shell'"));
bar_manager_set_display_separator_icon(bar_manager, string_copy("|"));
bar_manager_set_display_separator_icon_color(bar_manager, 0xffa8a8a8);
}
void bar_manager_begin(struct bar_manager *bar_manager)

View file

@ -18,6 +18,7 @@ struct bar_manager
char *_left_shell_icon;
char *_right_shell_icon;
char *position;
char *_display_separator_icon;
uint32_t height;
uint32_t padding_left;
uint32_t padding_right;
@ -25,6 +26,8 @@ struct bar_manager
uint32_t spacing_right;
bool title;
bool spaces;
bool spaces_for_all_displays;
bool display_separator;
bool clock;
bool power;
bool left_shell_on;
@ -39,12 +42,15 @@ struct bar_manager
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 battery_icon_color;
struct rgba_color power_icon_color;
struct rgba_color clock_icon_color;
struct rgba_color dnd_icon_color;
struct rgba_color left_shell_icon_color;
struct rgba_color right_shell_icon_color;
struct rgba_color display_separator_icon_color;
struct rgba_color background_color_dim;
struct bar_line *space_icon_strip;
struct bar_line space_icon;
@ -57,15 +63,19 @@ struct bar_manager
struct bar_line right_shell;
struct bar_line right_shell_icon;
struct bar_line center_shell;
struct bar_line display_separator_icon;
};
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);
void bar_manager_set_space_icon_color_secondary(struct bar_manager *bar_manager, uint32_t color);
void bar_manager_set_space_icon_color_tertiary(struct bar_manager *bar_manager, uint32_t color);
void bar_manager_set_battery_icon_color(struct bar_manager *bar_manager, uint32_t color);
void bar_manager_set_power_icon_color(struct bar_manager *bar_manager, uint32_t color);
void bar_manager_set_clock_icon_color(struct bar_manager *bar_manager, uint32_t color);
void bar_manager_set_dnd_icon_color(struct bar_manager *bar_manager, uint32_t color);
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_text_font(struct bar_manager *bar_manager, char *font_string);
@ -77,10 +87,13 @@ void bar_manager_set_clock_format(struct bar_manager *bar_manager, char *format)
void bar_manager_set_space_icon(struct bar_manager *bar_manager, char *icon);
void bar_manager_set_dnd_icon(struct bar_manager *bar_manager, char *icon);
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_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);
void bar_manager_set_spaces_for_all_displays(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);

View file

@ -15,6 +15,8 @@ extern bool g_verbose;
#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_BATTERY_ICON_COLOR "battery_icon_color"
#define COMMAND_CONFIG_BAR_POWER_ICON_COLOR "power_icon_color"
#define COMMAND_CONFIG_BAR_CLOCK_ICON_COLOR "clock_icon_color"
@ -35,6 +37,7 @@ extern bool g_verbose;
#define COMMAND_CONFIG_BAR_SPACING_RIGHT "spacing_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_CLOCK "clock"
#define COMMAND_CONFIG_BAR_POWER "power"
#define COMMAND_CONFIG_BAR_LEFT_SHELL "left_shell"
@ -47,6 +50,9 @@ extern bool g_verbose;
#define COMMAND_CONFIG_BAR_LEFT_SHELL_COMMAND "left_shell_command"
#define COMMAND_CONFIG_BAR_RIGHT_SHELL_COMMAND "right_shell_command"
#define COMMAND_CONFIG_BAR_CENTER_SHELL_COMMAND "center_shell_command"
#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"
/* --------------------------------COMMON ARGUMENTS----------------------------- */
#define ARGUMENT_COMMON_VAL_ON "on"
@ -242,6 +248,30 @@ 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_BATTERY_ICON_COLOR)) {
struct token value = get_token(&message);
if (!token_is_valid(value)) {
@ -344,78 +374,96 @@ static void handle_domain_config(FILE *rsp, struct token domain, char *message)
bar_manager_set_spacing_right(&g_bar_manager, atoi(token_to_string(token)));
}
} else if (token_equals(command, COMMAND_CONFIG_BAR_TITLE)) {
char * on = "on";
char * off = "off";
if (strcmp(message,on) == 0 && g_bar_manager.center_shell_on) {
struct token value = get_token(&message);
if (!token_is_valid(value)) {
fprintf(rsp, "%s\n", bool_str[g_bar_manager.title]);
} else if (token_equals(value, ARGUMENT_COMMON_VAL_ON) && g_bar_manager.center_shell_on) {
daemon_fail(rsp, "'%.*s' cannot be 'on' when 'center_shell' is 'on'.\n", command.length, command.text);
} else if (strcmp(message,on) == 0) {
bar_manager_set_title(&g_bar_manager, true);
} else if (strcmp(message,off) == 0) {
} else if (token_equals(value, ARGUMENT_COMMON_VAL_OFF)) {
bar_manager_set_title(&g_bar_manager, false);
} else if (token_equals(value, ARGUMENT_COMMON_VAL_ON)) {
bar_manager_set_title(&g_bar_manager, true);
} else {
daemon_fail(rsp, "value for '%.*s' must be either 'on' or 'off'.\n", command.length, command.text);
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)) {
char * on = "on";
char * off = "off";
if (strcmp(message,on) == 0) {
bar_manager_set_spaces(&g_bar_manager, true);
} else if (strcmp(message,off) == 0) {
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, "value for '%.*s' must be either 'on' or 'off'.\n", command.length, command.text);
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_CLOCK)) {
char * on = "on";
char * off = "off";
if (strcmp(message,on) == 0) {
bar_manager_set_clock(&g_bar_manager, true);
} else if (strcmp(message,off) == 0) {
struct token value = get_token(&message);
if (!token_is_valid(value)) {
fprintf(rsp, "%s\n", bool_str[g_bar_manager.clock]);
} else if (token_equals(value, ARGUMENT_COMMON_VAL_OFF)) {
bar_manager_set_clock(&g_bar_manager, false);
} else if (token_equals(value, ARGUMENT_COMMON_VAL_ON)) {
bar_manager_set_clock(&g_bar_manager, true);
} else {
daemon_fail(rsp, "value for '%.*s' must be either 'on' or 'off'.\n", command.length, command.text);
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_POWER)) {
char * on = "on";
char * off = "off";
if (strcmp(message,on) == 0) {
bar_manager_set_power(&g_bar_manager, true);
} else if (strcmp(message,off) == 0) {
struct token value = get_token(&message);
if (!token_is_valid(value)) {
fprintf(rsp, "%s\n", bool_str[g_bar_manager.power]);
} else if (token_equals(value, ARGUMENT_COMMON_VAL_OFF)) {
bar_manager_set_power(&g_bar_manager, false);
} else if (token_equals(value, ARGUMENT_COMMON_VAL_ON)) {
bar_manager_set_power(&g_bar_manager, true);
} else {
daemon_fail(rsp, "value for '%.*s' must be either 'on' or 'off'.\n", command.length, command.text);
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_LEFT_SHELL)) {
char * on = "on";
char * off = "off";
if (strcmp(message,on) == 0) {
bar_manager_set_left_shell(&g_bar_manager, true);
} else if (strcmp(message,off) == 0) {
struct token value = get_token(&message);
if (!token_is_valid(value)) {
fprintf(rsp, "%s\n", bool_str[g_bar_manager.left_shell_on]);
} else if (token_equals(value, ARGUMENT_COMMON_VAL_OFF)) {
bar_manager_set_left_shell(&g_bar_manager, false);
} else if (token_equals(value, ARGUMENT_COMMON_VAL_ON)) {
bar_manager_set_left_shell(&g_bar_manager, true);
} else {
daemon_fail(rsp, "value for '%.*s' must be either 'on' or 'off'.\n", command.length, command.text);
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_RIGHT_SHELL)) {
char * on = "on";
char * off = "off";
if (strcmp(message,on) == 0) {
bar_manager_set_right_shell(&g_bar_manager, true);
} else if (strcmp(message,off) == 0) {
struct token value = get_token(&message);
if (!token_is_valid(value)) {
fprintf(rsp, "%s\n", bool_str[g_bar_manager.right_shell_on]);
} else if (token_equals(value, ARGUMENT_COMMON_VAL_OFF)) {
bar_manager_set_right_shell(&g_bar_manager, false);
} else if (token_equals(value, ARGUMENT_COMMON_VAL_ON)) {
bar_manager_set_right_shell(&g_bar_manager, true);
} else {
daemon_fail(rsp, "value for '%.*s' must be either 'on' or 'off'.\n", command.length, command.text);
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_CENTER_SHELL)) {
char * on = "on";
char * off = "off";
if (strcmp(message,on) == 0 && g_bar_manager.title) {
struct token value = get_token(&message);
if (!token_is_valid(value)) {
fprintf(rsp, "%s\n", bool_str[g_bar_manager.center_shell_on]);
} else if (token_equals(value, ARGUMENT_COMMON_VAL_ON) && g_bar_manager.title) {
daemon_fail(rsp, "'%.*s' cannot be 'on' when 'title' is 'on'.\n", command.length, command.text);
} else if (strcmp(message,on) == 0) {
bar_manager_set_center_shell(&g_bar_manager, true);
} else if (strcmp(message,off) == 0) {
} else if (token_equals(value, ARGUMENT_COMMON_VAL_OFF)) {
bar_manager_set_center_shell(&g_bar_manager, false);
} else if (token_equals(value, ARGUMENT_COMMON_VAL_ON)) {
bar_manager_set_center_shell(&g_bar_manager, true);
} else {
daemon_fail(rsp, "value for '%.*s' must be either 'on' or 'off'.\n", command.length, command.text);
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_LEFT_SHELL_COMMAND)) {
int length = strlen(message);
@ -476,6 +524,36 @@ static void handle_domain_config(FILE *rsp, struct token domain, char *message)
} else {
bar_manager_set_left_shell_icon(&g_bar_manager, token_to_string(token));
}
} 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 {
daemon_fail(rsp, "unknown command '%.*s' for domain '%.*s'\n", command.length, command.text, domain.length, domain.text);