diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-04-18 21:07:33 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-04-18 21:07:33 +0200 |
commit | b05b89f404d44e2e2b3e675ccac09cfa7593eef4 (patch) | |
tree | bb3a2a6011058478db435b1985f6db9bd77ddf37 | |
parent | e58ddacdedf1a282b2c1a9cd4f301c29d0cf0d36 (diff) |
Always save absolute paths in ~/fehbg (closes #389)
-rw-r--r-- | src/wallpaper.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/wallpaper.c b/src/wallpaper.c index 2d3d3bc..8d15335 100644 --- a/src/wallpaper.c +++ b/src/wallpaper.c @@ -453,7 +453,9 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, if (home) { FILE *fp; char *path; + char *absolute_path; struct stat s; + gib_list *filelist_pos = filelist; path = estrjoin("/", home, ".fehbg", NULL); if ((fp = fopen(path, "w")) == NULL) { weprintf("Can't write to %s", path); @@ -461,7 +463,16 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, fputs("#!/bin/sh\n", fp); if (use_filelist) { for (int i = 0; i < cmdargc; i++) { - fputs(shell_escape(cmdargv[i]), fp); + if (filelist_pos && !strcmp(FEH_FILE(filelist_pos->data)->filename, cmdargv[i])) { + /* argument is a file */ + absolute_path = feh_absolute_path(cmdargv[i]); + fputs(shell_escape(absolute_path), fp); + filelist_pos = filelist_pos->next; + free(absolute_path); + } else { + /* argument is an option / option arg */ + fputs(shell_escape(cmdargv[i]), fp); + } fputc(' ', fp); } } else if (fil) { @@ -482,7 +493,9 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, fputs(" --no-xinerama", fp); #endif fputc(' ', fp); - fputs(shell_escape(fil), fp); + absolute_path = feh_absolute_path(fil); + fputs(shell_escape(absolute_path), fp); + free(absolute_path); } fputc('\n', fp); fclose(fp); |