mirror of
https://github.com/swaywm/sway.git
synced 2024-11-23 00:11:28 +00:00
Add initial support for custom bar-id
This commit is contained in:
parent
cf56c41c10
commit
c6b13163c9
|
@ -72,6 +72,13 @@ struct bar_config {
|
||||||
* In "show" mode, it will always be shown on top of the active workspace.
|
* In "show" mode, it will always be shown on top of the active workspace.
|
||||||
*/
|
*/
|
||||||
char *hidden_state;
|
char *hidden_state;
|
||||||
|
/**
|
||||||
|
* Id name used to identify the bar through IPC.
|
||||||
|
*
|
||||||
|
* Defaults to bar-x, where x corresponds to the position of the
|
||||||
|
* embedding bar block in the config file (bar-0, bar-1, ...).
|
||||||
|
*/
|
||||||
|
char *id;
|
||||||
uint32_t modifier;
|
uint32_t modifier;
|
||||||
enum desktop_shell_panel_position position;
|
enum desktop_shell_panel_position position;
|
||||||
char *status_command;
|
char *status_command;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "util.h"
|
||||||
#include "workspace.h"
|
#include "workspace.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "container.h"
|
#include "container.h"
|
||||||
|
@ -1124,9 +1125,20 @@ static struct cmd_results *cmd_bar(int argc, char **argv) {
|
||||||
bar->tray_padding = config->bar.tray_padding;
|
bar->tray_padding = config->bar.tray_padding;
|
||||||
list_add(config->bars, bar);
|
list_add(config->bars, bar);
|
||||||
|
|
||||||
|
// set bar id
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < config->bars->length; ++i) {
|
||||||
|
if (bar == config->bars->items[i]) {
|
||||||
|
const int len = 5 + numlen(i); // "bar-" + i + \0
|
||||||
|
bar->id = malloc(len * sizeof(char));
|
||||||
|
snprintf(bar->id, len, "bar-%d", i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set current bar
|
// Set current bar
|
||||||
config->current_bar = bar;
|
config->current_bar = bar;
|
||||||
sway_log(L_DEBUG, "Configuring bar");
|
sway_log(L_DEBUG, "Configuring bar %s", bar->id);
|
||||||
return cmd_results_new(CMD_BLOCK_BAR, NULL, NULL);
|
return cmd_results_new(CMD_BLOCK_BAR, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue