diff --git a/man/feh.pre b/man/feh.pre
index c2c1f002456168bf6ea6e7b4dc46cab192498310..fe4c92c9c92d5384c27fbbb2211af103dd3cd85f 100644
--- a/man/feh.pre
+++ b/man/feh.pre
@@ -667,8 +667,8 @@ be printed.
 .Sh BACKGROUND SETTING
 .
 .Nm
-can also be used as a background setter.  It will store the command line
-necessary to set the background in
+can also be used as a background setter.  Unless you pass the --bg-no-bgfile
+option, it will store the command line necessary to set the background in
 .Pa ~/.fehbg ,
 so to have your background restored everytime you start X, you can add
 .Qq eval $(cat ~/.fehbg)
@@ -726,6 +726,12 @@ Tile
 .Pq repeat
 the image in case it is too small for the screen
 .
+.It Cm --bg-no-bgfile
+.
+Do not write a
+.Pa ~/.fehbg
+file
+.
 .El
 .
 .
diff --git a/src/help.raw b/src/help.raw
index 48c8a709e8dd72e058a6c8659a688bf6ca9fbb90..d83f136597e86b14e3e772810e01e2d525b91e11 100644
--- a/src/help.raw
+++ b/src/help.raw
@@ -74,6 +74,7 @@ OPTIONS
                            fill the whole background, but the images' aspect
                            ratio may not be preserved
      --bg-tile FILE        Set FILE as tiled desktop background
+     --bg-no-bgfile        Do not write a ~/.fehbg file
  -C, --fontpath PATH       Specify an extra directory to look in for fonts,
                            can be used multiple times to add multiple paths.
  -M, --menu-font FONT      Use FONT for the font in menus.
diff --git a/src/options.c b/src/options.c
index b7eb5443f52ab261a33076050377cb362e32947f..e59adf694ff0c1984fb3216afa81c6fce4a40293 100644
--- a/src/options.c
+++ b/src/options.c
@@ -390,6 +390,7 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
 		{"thumb-redraw"  , 1, 0, 'J'},
 		{"info"          , 1, 0, 234},
 		{"force-aliasing", 0, 0, 235},
+		{"bg-no-bgfile"  , 0, 0, 236},
 
 		{0, 0, 0, 0}
 	};
@@ -703,6 +704,9 @@ static void feh_parse_option_array(int argc, char **argv, int finalrun)
 		case 235:
 			opt.force_aliasing = 1;
 			break;
+		case 236:
+			opt.no_bgfile = 1;
+			break;
 		default:
 			break;
 		}
@@ -760,6 +764,12 @@ static void check_options(void)
 		eprintf("You cannot combine --loadable with --unloadable");
 	}
 
+	if (opt.no_bgfile && !opt.bgmode) {
+		weprintf("The --no-bg-file option is meaningless unless you\n"
+				"are setting a background wallpaper image.\n"
+				"It is being ignored.");
+	}
+
 	return;
 }
 
diff --git a/src/options.h b/src/options.h
index 4946927662faf51d0b12a7ff7f3a67dfded6e56c..5192f9d9f52fce44877830d2c51f834517b818bc 100644
--- a/src/options.h
+++ b/src/options.h
@@ -68,6 +68,7 @@ struct __fehoptions {
 	unsigned char hold_actions[10];
 	unsigned char text_bg;
 	unsigned char image_bg;
+	unsigned char no_bgfile;
 
 	char *output_file;
 	char *output_dir;
diff --git a/src/wallpaper.c b/src/wallpaper.c
index 90b59e6f4a24d42295f8b317a9d174d3bacaacf8..773b87e0c77910287dfc1480947291060550625a 100644
--- a/src/wallpaper.c
+++ b/src/wallpaper.c
@@ -395,7 +395,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled,
 			fehbg = estrjoin(" ", "feh --bg-tile", filbuf, NULL);
 		}
 
-		if (fehbg) {
+		if (fehbg && !opt.no_bgfile) {
 			home = getenv("HOME");
 			if (home) {
 				FILE *fp;