aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/config.h7
-rw-r--r--sway/commands.c14
2 files changed, 20 insertions, 1 deletions
diff --git a/include/config.h b/include/config.h
index 04528e27..0f3ce550 100644
--- a/include/config.h
+++ b/include/config.h
@@ -72,6 +72,13 @@ struct bar_config {
72 * In "show" mode, it will always be shown on top of the active workspace. 72 * In "show" mode, it will always be shown on top of the active workspace.
73 */ 73 */
74 char *hidden_state; 74 char *hidden_state;
75 /**
76 * Id name used to identify the bar through IPC.
77 *
78 * Defaults to bar-x, where x corresponds to the position of the
79 * embedding bar block in the config file (bar-0, bar-1, ...).
80 */
81 char *id;
75 uint32_t modifier; 82 uint32_t modifier;
76 enum desktop_shell_panel_position position; 83 enum desktop_shell_panel_position position;
77 char *status_command; 84 char *status_command;
diff --git a/sway/commands.c b/sway/commands.c
index b0235dba..ea138dfc 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -15,6 +15,7 @@
15#include "layout.h" 15#include "layout.h"
16#include "focus.h" 16#include "focus.h"
17#include "log.h" 17#include "log.h"
18#include "util.h"
18#include "workspace.h" 19#include "workspace.h"
19#include "commands.h" 20#include "commands.h"
20#include "container.h" 21#include "container.h"
@@ -1124,9 +1125,20 @@ static struct cmd_results *cmd_bar(int argc, char **argv) {
1124 bar->tray_padding = config->bar.tray_padding; 1125 bar->tray_padding = config->bar.tray_padding;
1125 list_add(config->bars, bar); 1126 list_add(config->bars, bar);
1126 1127
1128 // set bar id
1129 int i;
1130 for (i = 0; i < config->bars->length; ++i) {
1131 if (bar == config->bars->items[i]) {
1132 const int len = 5 + numlen(i); // "bar-" + i + \0
1133 bar->id = malloc(len * sizeof(char));
1134 snprintf(bar->id, len, "bar-%d", i);
1135 break;
1136 }
1137 }
1138
1127 // Set current bar 1139 // Set current bar
1128 config->current_bar = bar; 1140 config->current_bar = bar;
1129 sway_log(L_DEBUG, "Configuring bar"); 1141 sway_log(L_DEBUG, "Configuring bar %s", bar->id);
1130 return cmd_results_new(CMD_BLOCK_BAR, NULL, NULL); 1142 return cmd_results_new(CMD_BLOCK_BAR, NULL, NULL);
1131} 1143}
1132 1144