Skip to content

Commit

Permalink
Default to all outputs when no output specified
Browse files Browse the repository at this point in the history
Before, `--output "*"` had to be specified on the cli before
any appearance options if trying to configure all outputs.
However, the manpage states that all outputs would be used by
default if none were specified.
  • Loading branch information
cjbassi authored and ddevault committed Apr 26, 2019
1 parent ec9fb9a commit cf62ace
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,10 @@ static void parse_command_line(int argc, char **argv,
"Background Modes:\n"
" stretch, fit, fill, center, tile, or solid_color\n";

struct swaybg_output_config *config = NULL;
struct swaybg_output_config *config = calloc(sizeof(struct swaybg_output_config), 1);
config->output = strdup("*");
config->mode = BACKGROUND_MODE_INVALID;
wl_list_init(&config->link); // init for safe removal

int c;
while (1) {
Expand All @@ -422,29 +425,20 @@ static void parse_command_line(int argc, char **argv,
}
switch (c) {
case 'c': // color
if (!config) {
goto no_output;
}
if (!is_valid_color(optarg)) {
swaybg_log(LOG_ERROR, "Invalid color: %s", optarg);
continue;
}
config->color = parse_color(optarg);
break;
case 'i': // image
if (!config) {
goto no_output;
}
free(config->image);
config->image = load_background_image(optarg);
if (!config->image) {
swaybg_log(LOG_ERROR, "Failed to load image: %s", optarg);
}
break;
case 'm': // mode
if (!config) {
goto no_output;
}
config->mode = parse_background_mode(optarg);
if (config->mode == BACKGROUND_MODE_INVALID) {
swaybg_log(LOG_ERROR, "Invalid mode: %s", optarg);
Expand Down Expand Up @@ -500,10 +494,6 @@ static void parse_command_line(int argc, char **argv,
: BACKGROUND_MODE_SOLID_COLOR;
}
}
return;
no_output:
fprintf(stderr, "Cannot operate on NULL output config\n");
exit(EXIT_FAILURE);
}

int main(int argc, char **argv) {
Expand Down

0 comments on commit cf62ace

Please sign in to comment.