diff options
author | Mykyta Holubakha <hilobakho@gmail.com> | 2016-05-08 10:20:28 +0300 |
---|---|---|
committer | Mykyta Holubakha <hilobakho@gmail.com> | 2016-05-08 22:59:06 +0300 |
commit | 500ee0a73151d1b5a76f34c5e7ce44ee873e5af9 (patch) | |
tree | 3d5b6fa83139f833ec20f3003a14027f03278b05 /sway/commands.c | |
parent | Merge pull request #645 from Hummer12007/floating_scroll (diff) | |
download | sway-500ee0a73151d1b5a76f34c5e7ce44ee873e5af9.tar.gz sway-500ee0a73151d1b5a76f34c5e7ce44ee873e5af9.tar.zst sway-500ee0a73151d1b5a76f34c5e7ce44ee873e5af9.zip |
Allow to set relative path for wallpapers in config
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sway/commands.c b/sway/commands.c index 5a592555..83f09788 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <unistd.h> | 10 | #include <unistd.h> |
11 | #include <ctype.h> | 11 | #include <ctype.h> |
12 | #include <wordexp.h> | 12 | #include <wordexp.h> |
13 | #include <libgen.h> | ||
13 | #include <sys/types.h> | 14 | #include <sys/types.h> |
14 | #include <sys/wait.h> | 15 | #include <sys/wait.h> |
15 | #include <limits.h> | 16 | #include <limits.h> |
@@ -1551,6 +1552,13 @@ static struct cmd_results *cmd_output(int argc, char **argv) { | |||
1551 | return cmd_results_new(CMD_INVALID, "output", "Invalid syntax (%s)", src); | 1552 | return cmd_results_new(CMD_INVALID, "output", "Invalid syntax (%s)", src); |
1552 | } | 1553 | } |
1553 | src = p.we_wordv[0]; | 1554 | src = p.we_wordv[0]; |
1555 | if (config->reading && *src != '/') { | ||
1556 | char *conf = strdup(config->current_config); | ||
1557 | char *conf_path = dirname(conf); | ||
1558 | src = malloc(strlen(conf_path) + strlen(src) + 2); | ||
1559 | sprintf(src, "%s/%s", conf_path, p.we_wordv[0]); | ||
1560 | free(conf); | ||
1561 | } | ||
1554 | if (access(src, F_OK) == -1) { | 1562 | if (access(src, F_OK) == -1) { |
1555 | return cmd_results_new(CMD_INVALID, "output", "Background file unreadable (%s)", src); | 1563 | return cmd_results_new(CMD_INVALID, "output", "Background file unreadable (%s)", src); |
1556 | } | 1564 | } |
@@ -1569,6 +1577,9 @@ static struct cmd_results *cmd_output(int argc, char **argv) { | |||
1569 | } | 1577 | } |
1570 | output->background = strdup(src); | 1578 | output->background = strdup(src); |
1571 | output->background_option = strdup(mode); | 1579 | output->background_option = strdup(mode); |
1580 | if (src != p.we_wordv[0]) { | ||
1581 | free(src); | ||
1582 | } | ||
1572 | wordfree(&p); | 1583 | wordfree(&p); |
1573 | } | 1584 | } |
1574 | } | 1585 | } |