diff --git a/include/sway/commands.h b/include/sway/commands.h index 3212c2cf..ceea1638 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -244,6 +244,7 @@ sway_cmd bar_colors_cmd_focused_separator; sway_cmd bar_colors_cmd_statusline; sway_cmd bar_colors_cmd_focused_statusline; sway_cmd bar_colors_cmd_urgent_workspace; +sway_cmd bar_colors_cmd_empty_workspace; sway_cmd input_cmd_seat; sway_cmd input_cmd_accel_profile; diff --git a/include/sway/config.h b/include/sway/config.h index aa58da53..8a104b16 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -387,6 +387,9 @@ struct bar_config { char *urgent_workspace_border; char *urgent_workspace_bg; char *urgent_workspace_text; + char *empty_workspace_border; + char *empty_workspace_bg; + char *empty_workspace_text; char *binding_mode_border; char *binding_mode_bg; char *binding_mode_text; diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index 3ad0bdf3..95b60a8f 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -86,6 +86,7 @@ struct swaybar_workspace { bool focused; bool visible; bool urgent; + bool empty; }; bool bar_setup(struct swaybar *bar, const char *socket_path); diff --git a/include/swaybar/config.h b/include/swaybar/config.h index 361acd99..b2d74fa3 100644 --- a/include/swaybar/config.h +++ b/include/swaybar/config.h @@ -65,6 +65,7 @@ struct swaybar_config { struct box_colors active_workspace; struct box_colors inactive_workspace; struct box_colors urgent_workspace; + struct box_colors empty_workspace; struct box_colors binding_mode; } colors; diff --git a/sway/commands/bar/colors.c b/sway/commands/bar/colors.c index 275fa3c6..01427f72 100644 --- a/sway/commands/bar/colors.c +++ b/sway/commands/bar/colors.c @@ -8,6 +8,7 @@ static const struct cmd_handler bar_colors_handlers[] = { { "active_workspace", bar_colors_cmd_active_workspace }, { "background", bar_colors_cmd_background }, { "binding_mode", bar_colors_cmd_binding_mode }, + { "empty_workspace", bar_colors_cmd_empty_workspace }, { "focused_background", bar_colors_cmd_focused_background }, { "focused_separator", bar_colors_cmd_focused_separator }, { "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); } + +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); +} diff --git a/sway/config/bar.c b/sway/config/bar.c index a8389244..04e2190d 100644 --- a/sway/config/bar.c +++ b/sway/config/bar.c @@ -67,6 +67,9 @@ void free_bar_config(struct bar_config *bar) { free(bar->colors.urgent_workspace_border); free(bar->colors.urgent_workspace_bg); 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_bg); 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))) { 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, // statusline, separator and urgent_workspace_*. bar->colors.focused_background = NULL; diff --git a/sway/ipc-json.c b/sway/ipc-json.c index f770e984..fb3d4085 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -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_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) { json_object_object_add(colors, "binding_mode_border", json_object_new_string(bar->colors.binding_mode_border)); diff --git a/swaybar/config.c b/swaybar/config.c index 5e828773..572501e8 100644 --- a/swaybar/config.c +++ b/swaybar/config.c @@ -73,6 +73,10 @@ struct swaybar_config *init_config(void) { config->colors.urgent_workspace.background = 0x900000FF; 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.background = 0x900000FF; config->colors.binding_mode.text = 0xFFFFFFFF; diff --git a/swaybar/ipc.c b/swaybar/ipc.c index 18dfd7ad..10a136d0 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c @@ -77,6 +77,9 @@ static void ipc_parse_colors( { "urgent_workspace_border", &config->colors.urgent_workspace.border }, { "urgent_workspace_bg", &config->colors.urgent_workspace.background }, { "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_bg", &config->colors.binding_mode.background }, { "binding_mode_text", &config->colors.binding_mode.text }, diff --git a/swaybar/render.c b/swaybar/render.c index 1113ca44..b814621f 100644 --- a/swaybar/render.c +++ b/swaybar/render.c @@ -623,6 +623,8 @@ static uint32_t render_workspace_button(struct render_context *ctx, box_colors = config->colors.focused_workspace; } else if (ws->visible) { box_colors = config->colors.active_workspace; + } else if (ws->empty) { + box_colors = config->colors.empty_workspace; } else { box_colors = config->colors.inactive_workspace; }