diff options
author | Mikkel Oscar Lyderik <mikkeloscar@gmail.com> | 2015-12-14 16:24:01 +0100 |
---|---|---|
committer | Mikkel Oscar Lyderik <mikkeloscar@gmail.com> | 2015-12-14 17:17:06 +0100 |
commit | c6b13163c93f7464ae21fa238fadc238b8ef2936 (patch) | |
tree | 4722e7006ea46d5b1ba30bd5113a7705f71338b8 | |
parent | Move sway/util.c to common/util.c (diff) | |
download | sway-c6b13163c93f7464ae21fa238fadc238b8ef2936.tar.gz sway-c6b13163c93f7464ae21fa238fadc238b8ef2936.tar.zst sway-c6b13163c93f7464ae21fa238fadc238b8ef2936.zip |
Add initial support for custom bar-id
-rw-r--r-- | include/config.h | 7 | ||||
-rw-r--r-- | sway/commands.c | 14 |
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 | ||