diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-08-08 16:42:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-08 16:42:33 -0400 |
commit | 78c0f013dd600f2877e93508ff4897daf0dc25a0 (patch) | |
tree | a628319cf9fe03e2e0c2ec0cd4a885b39cf7807d /swaybg/main.c | |
parent | fc039f0759c1293fc270b631b035176f6924797b (diff) | |
parent | 43d1ffc9ddf01eaf614293b5c8aeada27c3c9907 (diff) |
Merge pull request #2439 from RedSoxFan/fix-2434
Allow a fallback color to be specified for swaybg
Diffstat (limited to 'swaybg/main.c')
-rw-r--r-- | swaybg/main.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/swaybg/main.c b/swaybg/main.c index f8e7e7ef..5b0d0458 100644 --- a/swaybg/main.c +++ b/swaybg/main.c @@ -17,6 +17,7 @@ struct swaybg_args { int output_idx; const char *path; enum background_mode mode; + const char *fallback; }; struct swaybg_context { @@ -76,6 +77,10 @@ static void render_frame(struct swaybg_state *state) { cairo_set_source_u32(cairo, state->context.color); cairo_paint(cairo); } else { + if (state->args->fallback && state->context.color) { + cairo_set_source_u32(cairo, state->context.color); + cairo_paint(cairo); + } render_background_image(cairo, state->context.image, state->args->mode, buffer_width, buffer_height); } @@ -91,6 +96,9 @@ static bool prepare_context(struct swaybg_state *state) { state->context.color = parse_color(state->args->path); return is_valid_color(state->args->path); } + if (state->args->fallback && is_valid_color(state->args->fallback)) { + state->context.color = parse_color(state->args->fallback); + } if (!(state->context.image = load_background_image(state->args->path))) { return false; } @@ -190,7 +198,7 @@ int main(int argc, const char **argv) { state.args = &args; wlr_log_init(WLR_DEBUG, NULL); - if (argc != 4) { + if (argc < 4 || argc > 5) { wlr_log(WLR_ERROR, "Do not run this program manually. " "See man 5 sway and look for output options."); return 1; @@ -202,6 +210,9 @@ int main(int argc, const char **argv) { if (args.mode == BACKGROUND_MODE_INVALID) { return 1; } + + args.fallback = argc == 5 ? argv[4] : NULL; + if (!prepare_context(&state)) { return 1; } |