summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorWilliam Hua <william@attente.ca>2019-01-17 00:34:24 -0500
committerWilliam Hua <william@attente.ca>2019-01-17 07:41:10 -0500
commit8de5a06883b1b05553e05468178293f2592fab56 (patch)
tree4f776b4ef48fc80d83d951dd4b82b42b9b4f439e /main.c
parent0c1f193083166ccc56107028bb8b59d7aa767732 (diff)
Allow image file paths to contain colons
Colon characters are allowed in file paths, so if an image file named 'foo:bar.png' is passed as an --image argument, it's currently parsed as image 'bar.png' on output 'foo'. This fix allows the caller to pass the argument ':foo:bar.png' and treat an output of '' the same as NULL. This is assuming there will never be an output named '' however...
Diffstat (limited to 'main.c')
-rw-r--r--main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/main.c b/main.c
index 02d6e13..462316e 100644
--- a/main.c
+++ b/main.c
@@ -364,12 +364,12 @@ static cairo_surface_t *select_image(struct swaylock_state *state,
}
static void load_image(char *arg, struct swaylock_state *state) {
- // [<output>:]<path>
+ // [[<output>]:]<path>
struct swaylock_image *image = calloc(1, sizeof(struct swaylock_image));
char *separator = strchr(arg, ':');
if (separator) {
*separator = '\0';
- image->output_name = strdup(arg);
+ image->output_name = separator == arg ? NULL : strdup(arg);
image->path = strdup(separator + 1);
} else {
image->output_name = NULL;
@@ -554,7 +554,7 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
"Detach from the controlling terminal after locking.\n"
" -h, --help "
"Show help message and quit.\n"
- " -i, --image [<output>:]<path> "
+ " -i, --image [[<output>]:]<path> "
"Display the given image.\n"
" -L, --disable-caps-lock-text "
"Disable the Caps Lock text.\n"