mirror of
https://github.com/swaywm/sway.git
synced 2024-11-24 08:51:27 +00:00
Implement empty
workspaces in swaybar
This commit is contained in:
parent
d3ac856688
commit
173c918e43
|
@ -244,6 +244,7 @@ sway_cmd bar_colors_cmd_focused_separator;
|
||||||
sway_cmd bar_colors_cmd_statusline;
|
sway_cmd bar_colors_cmd_statusline;
|
||||||
sway_cmd bar_colors_cmd_focused_statusline;
|
sway_cmd bar_colors_cmd_focused_statusline;
|
||||||
sway_cmd bar_colors_cmd_urgent_workspace;
|
sway_cmd bar_colors_cmd_urgent_workspace;
|
||||||
|
sway_cmd bar_colors_cmd_empty_workspace;
|
||||||
|
|
||||||
sway_cmd input_cmd_seat;
|
sway_cmd input_cmd_seat;
|
||||||
sway_cmd input_cmd_accel_profile;
|
sway_cmd input_cmd_accel_profile;
|
||||||
|
|
|
@ -387,6 +387,9 @@ struct bar_config {
|
||||||
char *urgent_workspace_border;
|
char *urgent_workspace_border;
|
||||||
char *urgent_workspace_bg;
|
char *urgent_workspace_bg;
|
||||||
char *urgent_workspace_text;
|
char *urgent_workspace_text;
|
||||||
|
char *empty_workspace_border;
|
||||||
|
char *empty_workspace_bg;
|
||||||
|
char *empty_workspace_text;
|
||||||
char *binding_mode_border;
|
char *binding_mode_border;
|
||||||
char *binding_mode_bg;
|
char *binding_mode_bg;
|
||||||
char *binding_mode_text;
|
char *binding_mode_text;
|
||||||
|
|
|
@ -86,6 +86,7 @@ struct swaybar_workspace {
|
||||||
bool focused;
|
bool focused;
|
||||||
bool visible;
|
bool visible;
|
||||||
bool urgent;
|
bool urgent;
|
||||||
|
bool empty;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool bar_setup(struct swaybar *bar, const char *socket_path);
|
bool bar_setup(struct swaybar *bar, const char *socket_path);
|
||||||
|
|
|
@ -65,6 +65,7 @@ struct swaybar_config {
|
||||||
struct box_colors active_workspace;
|
struct box_colors active_workspace;
|
||||||
struct box_colors inactive_workspace;
|
struct box_colors inactive_workspace;
|
||||||
struct box_colors urgent_workspace;
|
struct box_colors urgent_workspace;
|
||||||
|
struct box_colors empty_workspace;
|
||||||
struct box_colors binding_mode;
|
struct box_colors binding_mode;
|
||||||
} colors;
|
} colors;
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ static const struct cmd_handler bar_colors_handlers[] = {
|
||||||
{ "active_workspace", bar_colors_cmd_active_workspace },
|
{ "active_workspace", bar_colors_cmd_active_workspace },
|
||||||
{ "background", bar_colors_cmd_background },
|
{ "background", bar_colors_cmd_background },
|
||||||
{ "binding_mode", bar_colors_cmd_binding_mode },
|
{ "binding_mode", bar_colors_cmd_binding_mode },
|
||||||
|
{ "empty_workspace", bar_colors_cmd_empty_workspace },
|
||||||
{ "focused_background", bar_colors_cmd_focused_background },
|
{ "focused_background", bar_colors_cmd_focused_background },
|
||||||
{ "focused_separator", bar_colors_cmd_focused_separator },
|
{ "focused_separator", bar_colors_cmd_focused_separator },
|
||||||
{ "focused_statusline", bar_colors_cmd_focused_statusline },
|
{ "focused_statusline", bar_colors_cmd_focused_statusline },
|
||||||
|
@ -150,3 +151,12 @@ struct cmd_results *bar_colors_cmd_urgent_workspace(int argc, char **argv) {
|
||||||
};
|
};
|
||||||
return parse_three_colors(colors, "urgent_workspace", argc, argv);
|
return parse_three_colors(colors, "urgent_workspace", argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct cmd_results *bar_colors_cmd_empty_workspace(int argc, char **argv) {
|
||||||
|
char **colors[3] = {
|
||||||
|
&(config->current_bar->colors.empty_workspace_border),
|
||||||
|
&(config->current_bar->colors.empty_workspace_bg),
|
||||||
|
&(config->current_bar->colors.empty_workspace_text)
|
||||||
|
};
|
||||||
|
return parse_three_colors(colors, "empty_workspace", argc, argv);
|
||||||
|
}
|
||||||
|
|
|
@ -67,6 +67,9 @@ void free_bar_config(struct bar_config *bar) {
|
||||||
free(bar->colors.urgent_workspace_border);
|
free(bar->colors.urgent_workspace_border);
|
||||||
free(bar->colors.urgent_workspace_bg);
|
free(bar->colors.urgent_workspace_bg);
|
||||||
free(bar->colors.urgent_workspace_text);
|
free(bar->colors.urgent_workspace_text);
|
||||||
|
free(bar->colors.empty_workspace_border);
|
||||||
|
free(bar->colors.empty_workspace_bg);
|
||||||
|
free(bar->colors.empty_workspace_text);
|
||||||
free(bar->colors.binding_mode_border);
|
free(bar->colors.binding_mode_border);
|
||||||
free(bar->colors.binding_mode_bg);
|
free(bar->colors.binding_mode_bg);
|
||||||
free(bar->colors.binding_mode_text);
|
free(bar->colors.binding_mode_text);
|
||||||
|
@ -161,6 +164,15 @@ struct bar_config *default_bar_config(void) {
|
||||||
if (!(bar->colors.urgent_workspace_text = strndup("#ffffffff", 9))) {
|
if (!(bar->colors.urgent_workspace_text = strndup("#ffffffff", 9))) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
if (!(bar->colors.empty_workspace_border = strndup("#000000ff", 9))) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
if (!(bar->colors.empty_workspace_bg = strndup("#000000ff", 9))) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
if (!(bar->colors.empty_workspace_text = strndup("#666666FF", 9))) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
// if the following colors stay undefined, they fall back to background,
|
// if the following colors stay undefined, they fall back to background,
|
||||||
// statusline, separator and urgent_workspace_*.
|
// statusline, separator and urgent_workspace_*.
|
||||||
bar->colors.focused_background = NULL;
|
bar->colors.focused_background = NULL;
|
||||||
|
|
|
@ -1307,6 +1307,13 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) {
|
||||||
json_object_object_add(colors, "urgent_workspace_text",
|
json_object_object_add(colors, "urgent_workspace_text",
|
||||||
json_object_new_string(bar->colors.urgent_workspace_text));
|
json_object_new_string(bar->colors.urgent_workspace_text));
|
||||||
|
|
||||||
|
json_object_object_add(colors, "empty_workspace_border",
|
||||||
|
json_object_new_string(bar->colors.empty_workspace_border));
|
||||||
|
json_object_object_add(colors, "empty_workspace_bg",
|
||||||
|
json_object_new_string(bar->colors.empty_workspace_bg));
|
||||||
|
json_object_object_add(colors, "empty_workspace_text",
|
||||||
|
json_object_new_string(bar->colors.empty_workspace_text));
|
||||||
|
|
||||||
if (bar->colors.binding_mode_border) {
|
if (bar->colors.binding_mode_border) {
|
||||||
json_object_object_add(colors, "binding_mode_border",
|
json_object_object_add(colors, "binding_mode_border",
|
||||||
json_object_new_string(bar->colors.binding_mode_border));
|
json_object_new_string(bar->colors.binding_mode_border));
|
||||||
|
|
|
@ -73,6 +73,10 @@ struct swaybar_config *init_config(void) {
|
||||||
config->colors.urgent_workspace.background = 0x900000FF;
|
config->colors.urgent_workspace.background = 0x900000FF;
|
||||||
config->colors.urgent_workspace.text = 0xFFFFFFFF;
|
config->colors.urgent_workspace.text = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
config->colors.empty_workspace.border = 0x000000FF;
|
||||||
|
config->colors.empty_workspace.background = 0x000000FF;
|
||||||
|
config->colors.empty_workspace.text = 0x666666FF;
|
||||||
|
|
||||||
config->colors.binding_mode.border = 0x2F343AFF;
|
config->colors.binding_mode.border = 0x2F343AFF;
|
||||||
config->colors.binding_mode.background = 0x900000FF;
|
config->colors.binding_mode.background = 0x900000FF;
|
||||||
config->colors.binding_mode.text = 0xFFFFFFFF;
|
config->colors.binding_mode.text = 0xFFFFFFFF;
|
||||||
|
|
|
@ -77,6 +77,9 @@ static void ipc_parse_colors(
|
||||||
{ "urgent_workspace_border", &config->colors.urgent_workspace.border },
|
{ "urgent_workspace_border", &config->colors.urgent_workspace.border },
|
||||||
{ "urgent_workspace_bg", &config->colors.urgent_workspace.background },
|
{ "urgent_workspace_bg", &config->colors.urgent_workspace.background },
|
||||||
{ "urgent_workspace_text", &config->colors.urgent_workspace.text },
|
{ "urgent_workspace_text", &config->colors.urgent_workspace.text },
|
||||||
|
{ "empty_workspace_border", &config->colors.empty_workspace.border },
|
||||||
|
{ "empty_workspace_bg", &config->colors.empty_workspace.background },
|
||||||
|
{ "empty_workspace_text", &config->colors.empty_workspace.text },
|
||||||
{ "binding_mode_border", &config->colors.binding_mode.border },
|
{ "binding_mode_border", &config->colors.binding_mode.border },
|
||||||
{ "binding_mode_bg", &config->colors.binding_mode.background },
|
{ "binding_mode_bg", &config->colors.binding_mode.background },
|
||||||
{ "binding_mode_text", &config->colors.binding_mode.text },
|
{ "binding_mode_text", &config->colors.binding_mode.text },
|
||||||
|
|
|
@ -623,6 +623,8 @@ static uint32_t render_workspace_button(struct render_context *ctx,
|
||||||
box_colors = config->colors.focused_workspace;
|
box_colors = config->colors.focused_workspace;
|
||||||
} else if (ws->visible) {
|
} else if (ws->visible) {
|
||||||
box_colors = config->colors.active_workspace;
|
box_colors = config->colors.active_workspace;
|
||||||
|
} else if (ws->empty) {
|
||||||
|
box_colors = config->colors.empty_workspace;
|
||||||
} else {
|
} else {
|
||||||
box_colors = config->colors.inactive_workspace;
|
box_colors = config->colors.inactive_workspace;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue