diff options
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/output/background.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/sway/commands/output/background.c b/sway/commands/output/background.c index 4ed56c2a..e45b571e 100644 --- a/sway/commands/output/background.c +++ b/sway/commands/output/background.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <errno.h> | 6 | #include <errno.h> |
7 | #include "sway/commands.h" | 7 | #include "sway/commands.h" |
8 | #include "sway/config.h" | 8 | #include "sway/config.h" |
9 | #include "sway/swaynag.h" | ||
9 | #include "log.h" | 10 | #include "log.h" |
10 | #include "stringop.h" | 11 | #include "stringop.h" |
11 | 12 | ||
@@ -36,6 +37,7 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { | |||
36 | output->background = calloc(1, strlen(argv[0]) + 3); | 37 | output->background = calloc(1, strlen(argv[0]) + 3); |
37 | snprintf(output->background, strlen(argv[0]) + 3, "\"%s\"", argv[0]); | 38 | snprintf(output->background, strlen(argv[0]) + 3, "\"%s\"", argv[0]); |
38 | output->background_option = strdup("solid_color"); | 39 | output->background_option = strdup("solid_color"); |
40 | output->background_fallback = NULL; | ||
39 | argc -= 2; argv += 2; | 41 | argc -= 2; argv += 2; |
40 | } else { | 42 | } else { |
41 | bool valid = false; | 43 | bool valid = false; |
@@ -104,16 +106,35 @@ struct cmd_results *output_cmd_background(int argc, char **argv) { | |||
104 | free(conf); | 106 | free(conf); |
105 | } | 107 | } |
106 | 108 | ||
107 | if (access(src, F_OK) == -1) { | 109 | bool can_access = access(src, F_OK) != -1; |
108 | struct cmd_results *cmd_res = cmd_results_new(CMD_FAILURE, "output", | 110 | if (!can_access) { |
109 | "Unable to access background file '%s': %s", src, strerror(errno)); | 111 | wlr_log(WLR_ERROR, "Unable to access background file '%s': %s", |
112 | src, strerror(errno)); | ||
113 | if (!config->validating) { | ||
114 | swaynag_log(config->swaynag_command, | ||
115 | &config->swaynag_config_errors, | ||
116 | "Unable to access background file '%s'", src); | ||
117 | } | ||
110 | free(src); | 118 | free(src); |
111 | return cmd_res; | 119 | } else { |
120 | output->background = src; | ||
121 | output->background_option = strdup(mode); | ||
112 | } | 122 | } |
113 | |||
114 | output->background = src; | ||
115 | output->background_option = strdup(mode); | ||
116 | argc -= j + 1; argv += j + 1; | 123 | argc -= j + 1; argv += j + 1; |
124 | |||
125 | output->background_fallback = NULL; | ||
126 | if (argc && *argv[0] == '#') { | ||
127 | output->background_fallback = calloc(1, strlen(argv[0]) + 3); | ||
128 | snprintf(output->background_fallback, strlen(argv[0]) + 3, | ||
129 | "\"%s\"", argv[0]); | ||
130 | argc--; argv++; | ||
131 | |||
132 | if (!can_access) { | ||
133 | output->background = output->background_fallback; | ||
134 | output->background_option = strdup("solid_color"); | ||
135 | output->background_fallback = NULL; | ||
136 | } | ||
137 | } | ||
117 | } | 138 | } |
118 | 139 | ||
119 | config->handler_context.leftovers.argc = argc; | 140 | config->handler_context.leftovers.argc = argc; |