summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/feh.pre8
-rw-r--r--src/wallpaper.c56
2 files changed, 35 insertions, 29 deletions
diff --git a/man/feh.pre b/man/feh.pre
index 01b6377..a6b76ef 100644
--- a/man/feh.pre
+++ b/man/feh.pre
@@ -965,14 +965,6 @@ So to have your background restored every time you start X, you can add
.Qq ~/.fehbg &
to your X startup script
.Pq such as Pa ~/.xinitrc .
-Note that
-.Pq unless the wallpaper is set via the menu
-.Nm
-saves the files and directories it was passed on the commandline, not the
-files which actually ended up as wallpaper.
-So, if you have randomization enabled,
-.Pa ~/.fehbg
-may set different wallpapers on each execution.
.
.Pp
.
diff --git a/src/wallpaper.c b/src/wallpaper.c
index 8d15335..4eaa660 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -461,6 +461,40 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
weprintf("Can't write to %s", path);
} else {
fputs("#!/bin/sh\n", fp);
+ fputs(cmdargv[0], fp);
+ fputs(" --bg-", fp);
+ if (centered)
+ fputs("center", fp);
+ else if (scaled)
+ fputs("scale", fp);
+ else if (filled)
+ fputs("fill", fp);
+ else
+ fputs("tile", fp);
+#ifdef HAVE_LIBXINERAMA
+ if (opt.xinerama) {
+ if (opt.xinerama_index >= 0) {
+ fprintf(fp, " --xinerama-index %d", opt.xinerama_index);
+ }
+ }
+ else {
+ fputs(" --no-xinerama", fp);
+ }
+#endif /* HAVE_LIBXINERAMA */
+ if (opt.geom_flags & XValue) {
+ fprintf(fp, " --geometry %c%d",
+ opt.geom_flags & XNegative ? '-' : '+',
+ opt.geom_flags & XNegative ? abs(opt.geom_x) : opt.geom_x);
+ if (opt.geom_flags & YValue) {
+ fprintf(fp, "%c%d",
+ opt.geom_flags & YNegative ? '-' : '+',
+ opt.geom_flags & YNegative ? abs(opt.geom_y) : opt.geom_y);
+ }
+ }
+ if (opt.force_aliasing) {
+ fputs(" --force-aliasing", fp);
+ }
+ fputc(' ', fp);
if (use_filelist) {
for (int i = 0; i < cmdargc; i++) {
if (filelist_pos && !strcmp(FEH_FILE(filelist_pos->data)->filename, cmdargv[i])) {
@@ -469,30 +503,10 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
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);
}
- fputc(' ', fp);
}
} else if (fil) {
- fputs("feh --bg-", fp);
- if (centered)
- fputs("center", fp);
- else if (scaled)
- fputs("scale", fp);
- else if (filled)
- fputs("fill", fp);
- else
- fputs("tile", fp);
-
- if (opt.force_aliasing)
- fputs(" --force-aliasing", fp);
-#ifdef HAVE_LIBXINERAMA
- if (!opt.xinerama)
- fputs(" --no-xinerama", fp);
-#endif
- fputc(' ', fp);
absolute_path = feh_absolute_path(fil);
fputs(shell_escape(absolute_path), fp);
free(absolute_path);