diff options
author | 2015-12-15 00:35:18 +0100 | |
---|---|---|
committer | 2015-12-15 01:05:00 +0100 | |
commit | 0513322c033d0d2c9c7aafaa95590c4d9320fcc8 (patch) | |
tree | fb469ff34a1ba6c5fffc242464acd10f5235ebca /sway | |
parent | Merge pull request #321 from gpyh/bar_cmds (diff) | |
download | sway-0513322c033d0d2c9c7aafaa95590c4d9320fcc8.tar.gz sway-0513322c033d0d2c9c7aafaa95590c4d9320fcc8.tar.zst sway-0513322c033d0d2c9c7aafaa95590c4d9320fcc8.zip |
Move default bar config to bar creation.
Get rid of `config->bar` and define the default bar config options when
a bar is initialized.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 18 | ||||
-rw-r--r-- | sway/config.c | 33 |
2 files changed, 22 insertions, 29 deletions
diff --git a/sway/commands.c b/sway/commands.c index 053f40fc..d2499e28 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -1126,22 +1126,8 @@ static struct cmd_results *cmd_bar(int argc, char **argv) { | |||
1126 | return cmd_results_new(CMD_FAILURE, "bar", "Can only be used in config file."); | 1126 | return cmd_results_new(CMD_FAILURE, "bar", "Can only be used in config file."); |
1127 | } | 1127 | } |
1128 | 1128 | ||
1129 | // Create new bar from default bar config | 1129 | // Create new bar with default values |
1130 | struct bar_config *bar = NULL; | 1130 | struct bar_config *bar = default_bar_config(); |
1131 | bar = malloc(sizeof*bar); | ||
1132 | bar->mode = strdup(config->bar.mode); | ||
1133 | bar->hidden_state = strdup(config->bar.hidden_state); | ||
1134 | bar->modifier = config->bar.modifier; | ||
1135 | bar->position = config->bar.position; | ||
1136 | bar->bindings = create_list(); | ||
1137 | bar->status_command = strdup(config->bar.status_command); | ||
1138 | bar->font = strdup(config->bar.font); | ||
1139 | bar->bar_height = config->bar.bar_height; | ||
1140 | bar->workspace_buttons = config->bar.workspace_buttons; | ||
1141 | bar->strip_workspace_numbers = config->bar.strip_workspace_numbers; | ||
1142 | bar->binding_mode_indicator = config->bar.binding_mode_indicator; | ||
1143 | bar->tray_padding = config->bar.tray_padding; | ||
1144 | list_add(config->bars, bar); | ||
1145 | 1131 | ||
1146 | // set bar id | 1132 | // set bar id |
1147 | int i; | 1133 | int i; |
diff --git a/sway/config.c b/sway/config.c index 2c2cc025..1302faa8 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -132,19 +132,6 @@ static void config_defaults(struct sway_config *config) { | |||
132 | config->edge_gaps = true; | 132 | config->edge_gaps = true; |
133 | config->gaps_inner = 0; | 133 | config->gaps_inner = 0; |
134 | config->gaps_outer = 0; | 134 | config->gaps_outer = 0; |
135 | |||
136 | // Bar | ||
137 | config->bar.mode = "dock"; | ||
138 | config->bar.hidden_state = "hide"; | ||
139 | config->bar.modifier = 0; | ||
140 | config->bar.position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; | ||
141 | config->bar.status_command = "while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done"; | ||
142 | config->bar.font = "monospace 10"; | ||
143 | config->bar.bar_height = -1; | ||
144 | config->bar.workspace_buttons = true; | ||
145 | config->bar.strip_workspace_numbers = false; | ||
146 | config->bar.binding_mode_indicator = true; | ||
147 | config->bar.tray_padding = 2; | ||
148 | } | 135 | } |
149 | 136 | ||
150 | static char *get_config_path(void) { | 137 | static char *get_config_path(void) { |
@@ -546,3 +533,23 @@ void free_sway_mouse_binding(struct sway_mouse_binding *binding) { | |||
546 | } | 533 | } |
547 | free(binding); | 534 | free(binding); |
548 | } | 535 | } |
536 | |||
537 | struct bar_config *default_bar_config(void) { | ||
538 | struct bar_config *bar = NULL; | ||
539 | bar = malloc(sizeof(struct bar_config)); | ||
540 | bar->mode = strdup("dock"); | ||
541 | bar->hidden_state = strdup("hide"); | ||
542 | bar->modifier = 0; | ||
543 | bar->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; | ||
544 | bar->bindings = create_list(); | ||
545 | bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done"); | ||
546 | bar->font = strdup("monospace 10"); | ||
547 | bar->bar_height = -1; | ||
548 | bar->workspace_buttons = true; | ||
549 | bar->strip_workspace_numbers = false; | ||
550 | bar->binding_mode_indicator = true; | ||
551 | bar->tray_padding = 2; | ||
552 | list_add(config->bars, bar); | ||
553 | |||
554 | return bar; | ||
555 | } | ||