aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2016-05-08 13:11:35 -0700
committerDrew DeVault <sir@cmpwn.com>2016-05-08 13:11:35 -0700
commit64db549c1887e1f4f360aa4c30343977ae9c640a (patch)
tree3d5b6fa83139f833ec20f3003a14027f03278b05 /sway/commands.c
parentdb0e1d6bc138100d351a41191f8e631d0b2b941e (diff)
parent500ee0a73151d1b5a76f34c5e7ce44ee873e5af9 (diff)
Merge pull request #648 from Hummer12007/relative_wallpaper
Allow to set relative path for wallpapers in config
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c11
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 @@
#include <unistd.h>
#include <ctype.h>
#include <wordexp.h>
+#include <libgen.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <limits.h>
@@ -1551,6 +1552,13 @@ static struct cmd_results *cmd_output(int argc, char **argv) {
return cmd_results_new(CMD_INVALID, "output", "Invalid syntax (%s)", src);
}
src = p.we_wordv[0];
+ if (config->reading && *src != '/') {
+ char *conf = strdup(config->current_config);
+ char *conf_path = dirname(conf);
+ src = malloc(strlen(conf_path) + strlen(src) + 2);
+ sprintf(src, "%s/%s", conf_path, p.we_wordv[0]);
+ free(conf);
+ }
if (access(src, F_OK) == -1) {
return cmd_results_new(CMD_INVALID, "output", "Background file unreadable (%s)", src);
}
@@ -1569,6 +1577,9 @@ static struct cmd_results *cmd_output(int argc, char **argv) {
}
output->background = strdup(src);
output->background_option = strdup(mode);
+ if (src != p.we_wordv[0]) {
+ free(src);
+ }
wordfree(&p);
}
}