diff options
Diffstat (limited to 'sway/config.c')
-rw-r--r-- | sway/config.c | 195 |
1 files changed, 135 insertions, 60 deletions
diff --git a/sway/config.c b/sway/config.c index e737f83c..4164cefa 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -29,21 +29,30 @@ struct sway_config *config = NULL; | |||
29 | static void terminate_swaybar(pid_t pid); | 29 | static void terminate_swaybar(pid_t pid); |
30 | 30 | ||
31 | static void free_variable(struct sway_variable *var) { | 31 | static void free_variable(struct sway_variable *var) { |
32 | if (!var) { | ||
33 | return; | ||
34 | } | ||
32 | free(var->name); | 35 | free(var->name); |
33 | free(var->value); | 36 | free(var->value); |
34 | free(var); | 37 | free(var); |
35 | } | 38 | } |
36 | 39 | ||
37 | static void free_binding(struct sway_binding *bind) { | 40 | static void free_binding(struct sway_binding *bind) { |
41 | if (!bind) { | ||
42 | return; | ||
43 | } | ||
38 | free_flat_list(bind->keys); | 44 | free_flat_list(bind->keys); |
39 | free(bind->command); | 45 | free(bind->command); |
40 | free(bind); | 46 | free(bind); |
41 | } | 47 | } |
42 | 48 | ||
43 | static void free_mode(struct sway_mode *mode) { | 49 | static void free_mode(struct sway_mode *mode) { |
50 | if (!mode) { | ||
51 | return; | ||
52 | } | ||
44 | free(mode->name); | 53 | free(mode->name); |
45 | int i; | 54 | int i; |
46 | for (i = 0; i < mode->bindings->length; ++i) { | 55 | for (i = 0; mode->bindings && i < mode->bindings->length; ++i) { |
47 | free_binding(mode->bindings->items[i]); | 56 | free_binding(mode->bindings->items[i]); |
48 | } | 57 | } |
49 | list_free(mode->bindings); | 58 | list_free(mode->bindings); |
@@ -51,13 +60,16 @@ static void free_mode(struct sway_mode *mode) { | |||
51 | } | 60 | } |
52 | 61 | ||
53 | static void free_bar(struct bar_config *bar) { | 62 | static void free_bar(struct bar_config *bar) { |
63 | if (!bar) { | ||
64 | return; | ||
65 | } | ||
54 | free(bar->mode); | 66 | free(bar->mode); |
55 | free(bar->hidden_state); | 67 | free(bar->hidden_state); |
56 | free(bar->status_command); | 68 | free(bar->status_command); |
57 | free(bar->font); | 69 | free(bar->font); |
58 | free(bar->separator_symbol); | 70 | free(bar->separator_symbol); |
59 | int i; | 71 | int i; |
60 | for (i = 0; i < bar->bindings->length; ++i) { | 72 | for (i = 0; bar->bindings && i < bar->bindings->length; ++i) { |
61 | free_sway_mouse_binding(bar->bindings->items[i]); | 73 | free_sway_mouse_binding(bar->bindings->items[i]); |
62 | } | 74 | } |
63 | list_free(bar->bindings); | 75 | list_free(bar->bindings); |
@@ -96,16 +108,25 @@ static void free_bar(struct bar_config *bar) { | |||
96 | } | 108 | } |
97 | 109 | ||
98 | void free_input_config(struct input_config *ic) { | 110 | void free_input_config(struct input_config *ic) { |
111 | if (!ic) { | ||
112 | return; | ||
113 | } | ||
99 | free(ic->identifier); | 114 | free(ic->identifier); |
100 | free(ic); | 115 | free(ic); |
101 | } | 116 | } |
102 | 117 | ||
103 | void free_output_config(struct output_config *oc) { | 118 | void free_output_config(struct output_config *oc) { |
119 | if (!oc) { | ||
120 | return; | ||
121 | } | ||
104 | free(oc->name); | 122 | free(oc->name); |
105 | free(oc); | 123 | free(oc); |
106 | } | 124 | } |
107 | 125 | ||
108 | static void free_workspace_output(struct workspace_output *wo) { | 126 | static void free_workspace_output(struct workspace_output *wo) { |
127 | if (!wo) { | ||
128 | return; | ||
129 | } | ||
109 | free(wo->output); | 130 | free(wo->output); |
110 | free(wo->workspace); | 131 | free(wo->workspace); |
111 | free(wo); | 132 | free(wo); |
@@ -134,6 +155,10 @@ void pid_workspace_add(struct pid_workspace *pw) { | |||
134 | struct pid_workspace *list_pw = NULL; | 155 | struct pid_workspace *list_pw = NULL; |
135 | struct timespec ts; | 156 | struct timespec ts; |
136 | time_t *now = malloc(sizeof(time_t)); | 157 | time_t *now = malloc(sizeof(time_t)); |
158 | if (!now) { | ||
159 | sway_log(L_ERROR, "Allocating time for pid_workspace failed"); | ||
160 | return; | ||
161 | } | ||
137 | 162 | ||
138 | pid_workspace_cleanup(); | 163 | pid_workspace_cleanup(); |
139 | 164 | ||
@@ -168,65 +193,74 @@ void free_pid_workspace(struct pid_workspace *pw) { | |||
168 | } | 193 | } |
169 | 194 | ||
170 | void free_command_policy(struct command_policy *policy) { | 195 | void free_command_policy(struct command_policy *policy) { |
196 | if (!policy) { | ||
197 | return; | ||
198 | } | ||
171 | free(policy->command); | 199 | free(policy->command); |
172 | free(policy); | 200 | free(policy); |
173 | } | 201 | } |
174 | 202 | ||
175 | void free_feature_policy(struct feature_policy *policy) { | 203 | void free_feature_policy(struct feature_policy *policy) { |
204 | if (!policy) { | ||
205 | return; | ||
206 | } | ||
176 | free(policy->program); | 207 | free(policy->program); |
177 | free(policy); | 208 | free(policy); |
178 | } | 209 | } |
179 | 210 | ||
180 | void free_config(struct sway_config *config) { | 211 | void free_config(struct sway_config *config) { |
212 | if (!config) { | ||
213 | return; | ||
214 | } | ||
181 | int i; | 215 | int i; |
182 | for (i = 0; i < config->symbols->length; ++i) { | 216 | for (i = 0; config->symbols && i < config->symbols->length; ++i) { |
183 | free_variable(config->symbols->items[i]); | 217 | free_variable(config->symbols->items[i]); |
184 | } | 218 | } |
185 | list_free(config->symbols); | 219 | list_free(config->symbols); |
186 | 220 | ||
187 | for (i = 0; i < config->modes->length; ++i) { | 221 | for (i = 0; config->modes && i < config->modes->length; ++i) { |
188 | free_mode(config->modes->items[i]); | 222 | free_mode(config->modes->items[i]); |
189 | } | 223 | } |
190 | list_free(config->modes); | 224 | list_free(config->modes); |
191 | 225 | ||
192 | for (i = 0; i < config->bars->length; ++i) { | 226 | for (i = 0; config->bars && i < config->bars->length; ++i) { |
193 | free_bar(config->bars->items[i]); | 227 | free_bar(config->bars->items[i]); |
194 | } | 228 | } |
195 | list_free(config->bars); | 229 | list_free(config->bars); |
196 | 230 | ||
197 | free_flat_list(config->cmd_queue); | 231 | free_flat_list(config->cmd_queue); |
198 | 232 | ||
199 | for (i = 0; i < config->workspace_outputs->length; ++i) { | 233 | for (i = 0; config->workspace_outputs && i < config->workspace_outputs->length; ++i) { |
200 | free_workspace_output(config->workspace_outputs->items[i]); | 234 | free_workspace_output(config->workspace_outputs->items[i]); |
201 | } | 235 | } |
202 | list_free(config->workspace_outputs); | 236 | list_free(config->workspace_outputs); |
203 | 237 | ||
204 | for (i = 0; i < config->pid_workspaces->length; ++i) { | 238 | for (i = 0; config->pid_workspaces && i < config->pid_workspaces->length; ++i) { |
205 | free_pid_workspace(config->pid_workspaces->items[i]); | 239 | free_pid_workspace(config->pid_workspaces->items[i]); |
206 | } | 240 | } |
207 | list_free(config->pid_workspaces); | 241 | list_free(config->pid_workspaces); |
208 | 242 | ||
209 | for (i = 0; i < config->criteria->length; ++i) { | 243 | for (i = 0; config->criteria && i < config->criteria->length; ++i) { |
210 | free_criteria(config->criteria->items[i]); | 244 | free_criteria(config->criteria->items[i]); |
211 | } | 245 | } |
212 | list_free(config->criteria); | 246 | list_free(config->criteria); |
213 | 247 | ||
214 | for (i = 0; i < config->input_configs->length; ++i) { | 248 | for (i = 0; config->input_configs && i < config->input_configs->length; ++i) { |
215 | free_input_config(config->input_configs->items[i]); | 249 | free_input_config(config->input_configs->items[i]); |
216 | } | 250 | } |
217 | list_free(config->input_configs); | 251 | list_free(config->input_configs); |
218 | 252 | ||
219 | for (i = 0; i < config->output_configs->length; ++i) { | 253 | for (i = 0; config->output_configs && i < config->output_configs->length; ++i) { |
220 | free_output_config(config->output_configs->items[i]); | 254 | free_output_config(config->output_configs->items[i]); |
221 | } | 255 | } |
222 | list_free(config->output_configs); | 256 | list_free(config->output_configs); |
223 | 257 | ||
224 | for (i = 0; i < config->command_policies->length; ++i) { | 258 | for (i = 0; config->command_policies && i < config->command_policies->length; ++i) { |
225 | free_command_policy(config->command_policies->items[i]); | 259 | free_command_policy(config->command_policies->items[i]); |
226 | } | 260 | } |
227 | list_free(config->command_policies); | 261 | list_free(config->command_policies); |
228 | 262 | ||
229 | for (i = 0; i < config->feature_policies->length; ++i) { | 263 | for (i = 0; config->feature_policies && i < config->feature_policies->length; ++i) { |
230 | free_feature_policy(config->feature_policies->items[i]); | 264 | free_feature_policy(config->feature_policies->items[i]); |
231 | } | 265 | } |
232 | list_free(config->feature_policies); | 266 | list_free(config->feature_policies); |
@@ -243,37 +277,37 @@ void free_config(struct sway_config *config) { | |||
243 | 277 | ||
244 | 278 | ||
245 | static bool file_exists(const char *path) { | 279 | static bool file_exists(const char *path) { |
246 | return access(path, R_OK) != -1; | 280 | return path && access(path, R_OK) != -1; |
247 | } | 281 | } |
248 | 282 | ||
249 | static void config_defaults(struct sway_config *config) { | 283 | static void config_defaults(struct sway_config *config) { |
250 | config->symbols = create_list(); | 284 | if (!(config->symbols = create_list())) goto cleanup; |
251 | config->modes = create_list(); | 285 | if (!(config->modes = create_list())) goto cleanup; |
252 | config->bars = create_list(); | 286 | if (!(config->bars = create_list())) goto cleanup; |
253 | config->workspace_outputs = create_list(); | 287 | if (!(config->workspace_outputs = create_list())) goto cleanup; |
254 | config->pid_workspaces = create_list(); | 288 | if (!(config->pid_workspaces = create_list())) goto cleanup; |
255 | config->criteria = create_list(); | 289 | if (!(config->criteria = create_list())) goto cleanup; |
256 | config->input_configs = create_list(); | 290 | if (!(config->input_configs = create_list())) goto cleanup; |
257 | config->output_configs = create_list(); | 291 | if (!(config->output_configs = create_list())) goto cleanup; |
258 | 292 | ||
259 | config->cmd_queue = create_list(); | 293 | if (!(config->cmd_queue = create_list())) goto cleanup; |
260 | 294 | ||
261 | config->current_mode = malloc(sizeof(struct sway_mode)); | 295 | if (!(config->current_mode = malloc(sizeof(struct sway_mode)))) goto cleanup; |
262 | config->current_mode->name = malloc(sizeof("default")); | 296 | if (!(config->current_mode->name = malloc(sizeof("default")))) goto cleanup; |
263 | strcpy(config->current_mode->name, "default"); | 297 | strcpy(config->current_mode->name, "default"); |
264 | config->current_mode->bindings = create_list(); | 298 | if (!(config->current_mode->bindings = create_list())) goto cleanup; |
265 | list_add(config->modes, config->current_mode); | 299 | list_add(config->modes, config->current_mode); |
266 | 300 | ||
267 | config->floating_mod = 0; | 301 | config->floating_mod = 0; |
268 | config->dragging_key = M_LEFT_CLICK; | 302 | config->dragging_key = M_LEFT_CLICK; |
269 | config->resizing_key = M_RIGHT_CLICK; | 303 | config->resizing_key = M_RIGHT_CLICK; |
270 | config->floating_scroll_up_cmd = strdup(""); | 304 | if (!(config->floating_scroll_up_cmd = strdup(""))) goto cleanup; |
271 | config->floating_scroll_down_cmd = strdup(""); | 305 | if (!(config->floating_scroll_down_cmd = strdup(""))) goto cleanup; |
272 | config->floating_scroll_left_cmd = strdup(""); | 306 | if (!(config->floating_scroll_left_cmd = strdup(""))) goto cleanup; |
273 | config->floating_scroll_right_cmd = strdup(""); | 307 | if (!(config->floating_scroll_right_cmd = strdup(""))) goto cleanup; |
274 | config->default_layout = L_NONE; | 308 | config->default_layout = L_NONE; |
275 | config->default_orientation = L_NONE; | 309 | config->default_orientation = L_NONE; |
276 | config->font = strdup("monospace 10"); | 310 | if (!(config->font = strdup("monospace 10"))) goto cleanup; |
277 | config->font_height = get_font_text_height(config->font); | 311 | config->font_height = get_font_text_height(config->font); |
278 | 312 | ||
279 | // floating view | 313 | // floating view |
@@ -297,9 +331,9 @@ static void config_defaults(struct sway_config *config) { | |||
297 | config->gaps_inner = 0; | 331 | config->gaps_inner = 0; |
298 | config->gaps_outer = 0; | 332 | config->gaps_outer = 0; |
299 | 333 | ||
300 | config->active_bar_modifiers = create_list(); | 334 | if (!(config->active_bar_modifiers = create_list())) goto cleanup; |
301 | 335 | ||
302 | config->config_chain = create_list(); | 336 | if (!(config->config_chain = create_list())) goto cleanup; |
303 | config->current_config = NULL; | 337 | config->current_config = NULL; |
304 | 338 | ||
305 | // borders | 339 | // borders |
@@ -343,9 +377,13 @@ static void config_defaults(struct sway_config *config) { | |||
343 | config->border_colors.background = 0xFFFFFFFF; | 377 | config->border_colors.background = 0xFFFFFFFF; |
344 | 378 | ||
345 | // Security | 379 | // Security |
346 | config->command_policies = create_list(); | 380 | if (!(config->command_policies = create_list())) goto cleanup; |
347 | config->feature_policies = create_list(); | 381 | if (!(config->feature_policies = create_list())) goto cleanup; |
348 | config->ipc_policy = UINT32_MAX; | 382 | config->ipc_policy = UINT32_MAX; |
383 | |||
384 | return; | ||
385 | cleanup: | ||
386 | sway_abort("Unable to allocate config structures"); | ||
349 | } | 387 | } |
350 | 388 | ||
351 | static int compare_modifiers(const void *left, const void *right) { | 389 | static int compare_modifiers(const void *left, const void *right) { |
@@ -386,11 +424,15 @@ static char *get_config_path(void) { | |||
386 | if (!getenv("XDG_CONFIG_HOME")) { | 424 | if (!getenv("XDG_CONFIG_HOME")) { |
387 | char *home = getenv("HOME"); | 425 | char *home = getenv("HOME"); |
388 | char *config_home = malloc(strlen(home) + strlen("/.config") + 1); | 426 | char *config_home = malloc(strlen(home) + strlen("/.config") + 1); |
389 | strcpy(config_home, home); | 427 | if (!config_home) { |
390 | strcat(config_home, "/.config"); | 428 | sway_log(L_ERROR, "Unable to allocate $HOME/.config"); |
391 | setenv("XDG_CONFIG_HOME", config_home, 1); | 429 | } else { |
392 | sway_log(L_DEBUG, "Set XDG_CONFIG_HOME to %s", config_home); | 430 | strcpy(config_home, home); |
393 | free(config_home); | 431 | strcat(config_home, "/.config"); |
432 | setenv("XDG_CONFIG_HOME", config_home, 1); | ||
433 | sway_log(L_DEBUG, "Set XDG_CONFIG_HOME to %s", config_home); | ||
434 | free(config_home); | ||
435 | } | ||
394 | } | 436 | } |
395 | 437 | ||
396 | wordexp_t p; | 438 | wordexp_t p; |
@@ -452,6 +494,9 @@ bool load_main_config(const char *file, bool is_active) { | |||
452 | 494 | ||
453 | struct sway_config *old_config = config; | 495 | struct sway_config *old_config = config; |
454 | config = calloc(1, sizeof(struct sway_config)); | 496 | config = calloc(1, sizeof(struct sway_config)); |
497 | if (!config) { | ||
498 | sway_abort("Unable to allocate config"); | ||
499 | } | ||
455 | 500 | ||
456 | config_defaults(config); | 501 | config_defaults(config); |
457 | if (is_active) { | 502 | if (is_active) { |
@@ -491,6 +536,10 @@ static bool load_include_config(const char *path, const char *parent_dir, struct | |||
491 | if (len >= 1 && path[0] != '/') { | 536 | if (len >= 1 && path[0] != '/') { |
492 | len = len + strlen(parent_dir) + 2; | 537 | len = len + strlen(parent_dir) + 2; |
493 | full_path = malloc(len * sizeof(char)); | 538 | full_path = malloc(len * sizeof(char)); |
539 | if (!full_path) { | ||
540 | sway_log(L_ERROR, "Unable to allocate full path to included config"); | ||
541 | return false; | ||
542 | } | ||
494 | snprintf(full_path, len, "%s/%s", parent_dir, path); | 543 | snprintf(full_path, len, "%s/%s", parent_dir, path); |
495 | } | 544 | } |
496 | 545 | ||
@@ -575,6 +624,9 @@ bool read_config(FILE *file, struct sway_config *config) { | |||
575 | char *line; | 624 | char *line; |
576 | while (!feof(file)) { | 625 | while (!feof(file)) { |
577 | line = read_line(file); | 626 | line = read_line(file); |
627 | if (!line) { | ||
628 | continue; | ||
629 | } | ||
578 | line_number++; | 630 | line_number++; |
579 | line = strip_whitespace(line); | 631 | line = strip_whitespace(line); |
580 | if (line[0] == '#') { | 632 | if (line[0] == '#') { |
@@ -816,6 +868,10 @@ static void invoke_swaybar(struct bar_config *bar) { | |||
816 | // run custom swaybar | 868 | // run custom swaybar |
817 | int len = strlen(bar->swaybar_command) + strlen(bar->id) + 5; | 869 | int len = strlen(bar->swaybar_command) + strlen(bar->id) + 5; |
818 | char *command = malloc(len * sizeof(char)); | 870 | char *command = malloc(len * sizeof(char)); |
871 | if (!command) { | ||
872 | sway_log(L_ERROR, "Unable to allocate swaybar command string"); | ||
873 | return; | ||
874 | } | ||
819 | snprintf(command, len, "%s -b %s", bar->swaybar_command, bar->id); | 875 | snprintf(command, len, "%s -b %s", bar->swaybar_command, bar->id); |
820 | 876 | ||
821 | char *const cmd[] = { | 877 | char *const cmd[] = { |
@@ -1052,6 +1108,11 @@ char *do_var_replacement(char *str) { | |||
1052 | if (strncmp(find, var->name, vnlen) == 0) { | 1108 | if (strncmp(find, var->name, vnlen) == 0) { |
1053 | int vvlen = strlen(var->value); | 1109 | int vvlen = strlen(var->value); |
1054 | char *newstr = malloc(strlen(str) - vnlen + vvlen + 1); | 1110 | char *newstr = malloc(strlen(str) - vnlen + vvlen + 1); |
1111 | if (!newstr) { | ||
1112 | sway_log(L_ERROR, | ||
1113 | "Unable to allocate replacement during variable expansion"); | ||
1114 | break; | ||
1115 | } | ||
1055 | char *newptr = newstr; | 1116 | char *newptr = newstr; |
1056 | int offset = find - str; | 1117 | int offset = find - str; |
1057 | strncpy(newptr, str, offset); | 1118 | strncpy(newptr, str, offset); |
@@ -1185,6 +1246,9 @@ void free_sway_mouse_binding(struct sway_mouse_binding *binding) { | |||
1185 | 1246 | ||
1186 | struct sway_binding *sway_binding_dup(struct sway_binding *sb) { | 1247 | struct sway_binding *sway_binding_dup(struct sway_binding *sb) { |
1187 | struct sway_binding *new_sb = malloc(sizeof(struct sway_binding)); | 1248 | struct sway_binding *new_sb = malloc(sizeof(struct sway_binding)); |
1249 | if (!new_sb) { | ||
1250 | return NULL; | ||
1251 | } | ||
1188 | 1252 | ||
1189 | new_sb->order = sb->order; | 1253 | new_sb->order = sb->order; |
1190 | new_sb->modifiers = sb->modifiers; | 1254 | new_sb->modifiers = sb->modifiers; |
@@ -1194,6 +1258,10 @@ struct sway_binding *sway_binding_dup(struct sway_binding *sb) { | |||
1194 | int i; | 1258 | int i; |
1195 | for (i = 0; i < sb->keys->length; ++i) { | 1259 | for (i = 0; i < sb->keys->length; ++i) { |
1196 | xkb_keysym_t *key = malloc(sizeof(xkb_keysym_t)); | 1260 | xkb_keysym_t *key = malloc(sizeof(xkb_keysym_t)); |
1261 | if (!key) { | ||
1262 | free_sway_binding(new_sb); | ||
1263 | return NULL; | ||
1264 | } | ||
1197 | *key = *(xkb_keysym_t *)sb->keys->items[i]; | 1265 | *key = *(xkb_keysym_t *)sb->keys->items[i]; |
1198 | list_add(new_sb->keys, key); | 1266 | list_add(new_sb->keys, key); |
1199 | } | 1267 | } |
@@ -1204,13 +1272,16 @@ struct sway_binding *sway_binding_dup(struct sway_binding *sb) { | |||
1204 | struct bar_config *default_bar_config(void) { | 1272 | struct bar_config *default_bar_config(void) { |
1205 | struct bar_config *bar = NULL; | 1273 | struct bar_config *bar = NULL; |
1206 | bar = malloc(sizeof(struct bar_config)); | 1274 | bar = malloc(sizeof(struct bar_config)); |
1207 | bar->mode = strdup("dock"); | 1275 | if (!bar) { |
1208 | bar->hidden_state = strdup("hide"); | 1276 | return NULL; |
1277 | } | ||
1278 | if (!(bar->mode = strdup("dock"))) goto cleanup; | ||
1279 | if (!(bar->hidden_state = strdup("hide"))) goto cleanup; | ||
1209 | bar->modifier = WLC_BIT_MOD_LOGO; | 1280 | bar->modifier = WLC_BIT_MOD_LOGO; |
1210 | bar->outputs = NULL; | 1281 | bar->outputs = NULL; |
1211 | bar->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; | 1282 | bar->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; |
1212 | bar->bindings = create_list(); | 1283 | if (!(bar->bindings = create_list())) goto cleanup; |
1213 | bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done"); | 1284 | if (!(bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done"))) goto cleanup; |
1214 | bar->pango_markup = false; | 1285 | bar->pango_markup = false; |
1215 | bar->swaybar_command = NULL; | 1286 | bar->swaybar_command = NULL; |
1216 | bar->font = NULL; | 1287 | bar->font = NULL; |
@@ -1224,21 +1295,21 @@ struct bar_config *default_bar_config(void) { | |||
1224 | bar->verbose = false; | 1295 | bar->verbose = false; |
1225 | bar->pid = 0; | 1296 | bar->pid = 0; |
1226 | // set default colors | 1297 | // set default colors |
1227 | bar->colors.background = strndup("#000000ff", 9); | 1298 | if (!(bar->colors.background = strndup("#000000ff", 9))) goto cleanup; |
1228 | bar->colors.statusline = strndup("#ffffffff", 9); | 1299 | if (!(bar->colors.statusline = strndup("#ffffffff", 9))) goto cleanup; |
1229 | bar->colors.separator = strndup("#666666ff", 9); | 1300 | if (!(bar->colors.separator = strndup("#666666ff", 9))) goto cleanup; |
1230 | bar->colors.focused_workspace_border = strndup("#4c7899ff", 9); | 1301 | if (!(bar->colors.focused_workspace_border = strndup("#4c7899ff", 9))) goto cleanup; |
1231 | bar->colors.focused_workspace_bg = strndup("#285577ff", 9); | 1302 | if (!(bar->colors.focused_workspace_bg = strndup("#285577ff", 9))) goto cleanup; |
1232 | bar->colors.focused_workspace_text = strndup("#ffffffff", 9); | 1303 | if (!(bar->colors.focused_workspace_text = strndup("#ffffffff", 9))) goto cleanup; |
1233 | bar->colors.active_workspace_border = strndup("#333333ff", 9); | 1304 | if (!(bar->colors.active_workspace_border = strndup("#333333ff", 9))) goto cleanup; |
1234 | bar->colors.active_workspace_bg = strndup("#5f676aff", 9); | 1305 | if (!(bar->colors.active_workspace_bg = strndup("#5f676aff", 9))) goto cleanup; |
1235 | bar->colors.active_workspace_text = strndup("#ffffffff", 9); | 1306 | if (!(bar->colors.active_workspace_text = strndup("#ffffffff", 9))) goto cleanup; |
1236 | bar->colors.inactive_workspace_border = strndup("#333333ff", 9); | 1307 | if (!(bar->colors.inactive_workspace_border = strndup("#333333ff", 9))) goto cleanup; |
1237 | bar->colors.inactive_workspace_bg = strndup("#222222ff", 9); | 1308 | if (!(bar->colors.inactive_workspace_bg = strndup("#222222ff", 9))) goto cleanup; |
1238 | bar->colors.inactive_workspace_text = strndup("#888888ff", 9); | 1309 | if (!(bar->colors.inactive_workspace_text = strndup("#888888ff", 9))) goto cleanup; |
1239 | bar->colors.urgent_workspace_border = strndup("#2f343aff", 9); | 1310 | if (!(bar->colors.urgent_workspace_border = strndup("#2f343aff", 9))) goto cleanup; |
1240 | bar->colors.urgent_workspace_bg = strndup("#900000ff", 9); | 1311 | if (!(bar->colors.urgent_workspace_bg = strndup("#900000ff", 9))) goto cleanup; |
1241 | bar->colors.urgent_workspace_text = strndup("#ffffffff", 9); | 1312 | if (!(bar->colors.urgent_workspace_text = strndup("#ffffffff", 9))) goto cleanup; |
1242 | // if the following colors stay undefined, they fall back to background, | 1313 | // if the following colors stay undefined, they fall back to background, |
1243 | // statusline, separator and urgent_workspace_*. | 1314 | // statusline, separator and urgent_workspace_*. |
1244 | bar->colors.focused_background = NULL; | 1315 | bar->colors.focused_background = NULL; |
@@ -1251,4 +1322,8 @@ struct bar_config *default_bar_config(void) { | |||
1251 | list_add(config->bars, bar); | 1322 | list_add(config->bars, bar); |
1252 | 1323 | ||
1253 | return bar; | 1324 | return bar; |
1325 | |||
1326 | cleanup: | ||
1327 | free_bar(bar); | ||
1328 | return NULL; | ||
1254 | } | 1329 | } |