From 2092e092d813d8dc983091221a4e849162119872 Mon Sep 17 00:00:00 2001 From: Nazar Vinnichuk Date: Wed, 16 Sep 2020 20:03:42 +0300 Subject: [PATCH] Set $W to the absolute path. --- examples/hook/gsettings | 2 +- src/main.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/hook/gsettings b/examples/hook/gsettings index 3de2feb..0438efe 100644 --- a/examples/hook/gsettings +++ b/examples/hook/gsettings @@ -1,3 +1,3 @@ hook: "S=$(xdpyinfo | grep dimensions | sed -r \"s/^[^0-9]*([0-9]+x[0-9]+).*$/\1/\");" "convert '$W' -gravity center -background '#073642' -extent '$S' '$W';" - "gsettings set org.gnome.desktop.background picture-uri '$(realpath '$W')';" + "gsettings set org.gnome.desktop.background picture-uri '$W';" diff --git a/src/main.c b/src/main.c index 2b367bc..a04e9de 100644 --- a/src/main.c +++ b/src/main.c @@ -19,7 +19,12 @@ int main(int argc, char **argv) { } if (!opts._skip_hook && opts.hook != NULL) { - setenv("W", "./pacwall.png", 1); + char *cwd = getcwd(NULL, 0); + char *w = malloc(strlen(cwd) + strlen("/pacwall.png") + 1); + stpcpy(stpcpy(w, cwd), "/pacwall.png"); + free(cwd); + setenv("W", w, 1); + execlp(opts.shell, opts.shell, "-c", opts.hook, (char *)NULL); panic("Could not execute shell %s: %s", opts.shell, strerror(errno)); }